Skip to content

Commit

Permalink
[Form] Fixed: RepeatedType now maps all errors to the first field
Browse files Browse the repository at this point in the history
  • Loading branch information
webmozart committed May 22, 2012
1 parent 215b687 commit 9eda5f5
Showing 1 changed file with 7 additions and 0 deletions.
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\Extension\Core\DataTransformer\ValueToDuplicatesTransformer;
use Symfony\Component\OptionsResolver\Options;

class RepeatedType extends AbstractType
{
Expand Down Expand Up @@ -41,6 +42,11 @@ public function buildForm(FormBuilder $builder, array $options)
*/
public function getDefaultOptions()
{
// Map errors to the first field
$errorMapping = function (Options $options) {
return array('.' => $options['first_name']);
};

return array(
'type' => 'text',
'options' => array(),
Expand All @@ -49,6 +55,7 @@ public function getDefaultOptions()
'first_name' => 'first',
'second_name' => 'second',
'error_bubbling' => false,
'error_mapping' => $errorMapping,
);
}

Expand Down

0 comments on commit 9eda5f5

Please sign in to comment.