8000 [Form] Fixed: RepeatedType now maps all errors to the first field · symfony/symfony@9eda5f5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9eda5f5

Browse files
committed
[Form] Fixed: RepeatedType now maps all errors to the first field
1 parent 215b687 commit 9eda5f5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Symfony/Component/Form/Extension/Core/Type/RepeatedType.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Form\AbstractType;
1515
use Symfony\Component\Form\FormBuilder;
1616
use Symfony\Component\Form\Extension\Core\DataTransformer\ValueToDuplicatesTransformer;
17+
use Symfony\Component\OptionsResolver\Options;
1718

1819
class RepeatedType extends AbstractType
1920
{
@@ -41,6 +42,11 @@ public function buildForm(FormBuilder $builder, array $options)
4142
*/
4243
public function getDefaultOptions()
4344
{
45+
// Map errors to the first field
46+
$errorMapping = function (Options $options) {
47+
return array('.' => $options['first_name']);
48+
};
49+
4450
return array(
4551
'type' => 'text',
4652
'options' => array(),
@@ -49,6 +55,7 @@ public function getDefaultOptions()
4955
'first_name' => 'first',
5056
'second_name' => 'second',
5157
'error_bubbling' => false,
58+
'error_mapping' => $errorMapping,
5259
);
5360
}
5461

0 commit comments

Comments
 (0)
0