Skip to content

[Form] Errors are not displayed for the fields of the collection type #12936

@sergeyfedotov

Description

@sergeyfedotov

Errors are not associated with the field when the indices has a gap.

The errors are displayed for both fields.

<input type="text" id="post_photos_0_fileName" name="post[photos][0][fileName]" value="" />
<input type="text" id="post_photos_1_fileName" name="post[photos][1][fileName]" value="" />

Errors are only displayed for the first field.

<input type="text" id="post_photos_0_fileName" name="post[photos][0][fileName]" value="" />
<input type="text" id="post_photos_2_fileName" name="post[photos][2][fileName]" value="" />
public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder->add(
        'photos',
        'collection',
        array(
            'type'          => new PhotoType(),
            'allow_add'     => true,
            'allow_delete'  => true,
            'prototype'     => true,
            'by_reference'  => false
        )

    );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions