[Form] Fixed: RepeatedType now maps all errors to the first field
This commit is contained in:
parent
215b687b7b
commit
9eda5f5872
@ -14,6 +14,7 @@ namespace Symfony\Component\Form\Extension\Core\Type;
|
|||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilder;
|
use Symfony\Component\Form\FormBuilder;
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\ValueToDuplicatesTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\ValueToDuplicatesTransformer;
|
||||||
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
|
|
||||||
class RepeatedType extends AbstractType
|
class RepeatedType extends AbstractType
|
||||||
{
|
{
|
||||||
@ -41,6 +42,11 @@ class RepeatedType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function getDefaultOptions()
|
||||||
{
|
{
|
||||||
|
// Map errors to the first field
|
||||||
|
$errorMapping = function (Options $options) {
|
||||||
|
return array('.' => $options['first_name']);
|
||||||
|
};
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'options' => array(),
|
'options' => array(),
|
||||||
@ -49,6 +55,7 @@ class RepeatedType extends AbstractType
|
|||||||
'first_name' => 'first',
|
'first_name' => 'first',
|
||||||
'second_name' => 'second',
|
'second_name' => 'second',
|
||||||
'error_bubbling' => false,
|
'error_bubbling' => false,
|
||||||
|
'error_mapping' => $errorMapping,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user