[Form] Fixed: "error_mapping" is not an attribute anymore, but an option

This commit is contained in:
Bernhard Schussek 2012-05-25 16:50:31 +02:00
parent 023dbf809a
commit 8c23d7fdfe
2 changed files with 6 additions and 5 deletions

View File

@ -109,12 +109,12 @@ class ViolationMapper implements ViolationMapperInterface
}
// Follow dot rules until we have the final target
$mapping = $this->scope->getConfig()->getAttribute('error_mapping');
$mapping = $this->scope->getConfig()->getOption('error_mapping');
while ($this->isValidScope() && isset($mapping['.'])) {
$dotRule = new MappingRule($this->scope, '.', $mapping['.']);
$this->scope = $dotRule->getTarget();
$mapping = $this->scope->getConfig()->getAttribute('error_mapping');
$mapping = $this->scope->getConfig()->getOption('error_mapping');
}
// Only add the error if the form is synchronized
@ -281,7 +281,7 @@ class ViolationMapper implements ViolationMapperInterface
$this->children = new \RecursiveIteratorIterator(
new VirtualFormAwareIterator($form->all())
);
foreach ($form->getConfig()->getAttribute('error_mapping') as $propertyPath => $targetPath) {
foreach ($form->getConfig()->getOption('error_mapping') as $propertyPath => $targetPath) {
// Dot rules are considered at the very end
if ('.' !== $propertyPath) {
$this->rules[] = new MappingRule($form, $propertyPath, $targetPath);

View File

@ -68,11 +68,12 @@ class ViolationMapperTest extends \PHPUnit_Framework_TestCase
protected function getForm($name = 'name', $propertyPath = null, $dataClass = null, $errorMapping = array(), $virtual = false, $synchronized = true)
{
$config = new FormConfig($name, $dataClass, $this->dispatcher);
$config = new FormConfig($name, $dataClass, $this->dispatcher, array(
'error_mapping' => $errorMapping,
));
$config->setMapped(true);
$config->setVirtual($virtual);
$config->setPropertyPath($propertyPath);
$config->setAttribute('error_mapping', $errorMapping);
if (!$synchronized) {
$config->addViewTransformer(new CallbackTransformer(