Skip to content

Commit

Permalink
[Form] Fixed: "error_mapping" is not an attribute anymore, but an option
Browse files Browse the repository at this point in the history
  • Loading branch information
webmozart committed May 25, 2012
1 parent 023dbf8 commit 8c23d7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Expand Up @@ -109,12 +109,12 @@ public function mapViolation(ConstraintViolation $violation, FormInterface $form
}

// 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
Expand Down Expand Up @@ -281,7 +281,7 @@ private function setScope(FormInterface $form)
$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);
Expand Down
Expand Up @@ -68,11 +68,12 @@ protected function setUp()

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(
Expand Down

0 comments on commit 8c23d7f

Please sign in to comment.