Skip to content

[Form][DelegatingValidator] RepeatedType error keeps on bubbling to root form #1971

Closed
@andrejpavlovic

Description

@andrejpavlovic

When RepeatedType is nested inside another form, error messages such as "This value should not be blank" bubble up to the root form, instead of appearing above the field in the nested form.

To illustrate this issue, I have put together the following example:

  • Two types where one is nested in the other (child inside parent).
  • Both types have the RepeatedType field.
  • Both RepeatedType fields are NotBlank.

As you can see, the error message for the RepeatedType in the main type, appears right above the fields, but this doesn't happen for the nested type.

Screenshot

Here are the types and models that can be used to demonstrate the issue:

class RegistrationParent
{
    public $registrationChild;

    /**
     * @Assert\NotBlank()
     */
    public $plainPassword;
}


class RegistrationChild
{
    /**
     * @Assert\NotBlank()
     */
    public $plainPassword;
}


class RegistrationParentFormType extends AbstractType
{
   public function buildForm(FormBuilder $builder, array $options)
   {
   $builder
      ->add('registrationChild', new RegistrationChildFormType())
      ->add('plainPassword', 'repeated', array(
         'type' => 'password',
      ))
   ;
 }


class RegistrationChildFormType extends AbstractType
{
   public function buildForm(FormBuilder $builder, array $options)
   {
      $builder
         ->add('plainPassword', 'repeated', array(
            'type' => 'password',
         ))
      ;
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugFormGood first issueIdeal for your first contribution! (some Symfony experience may be required)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions