8000 [Form] Errors are not displayed for the fields of the collection type · Issue #12936 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sergeyfedotov opened this issue Dec 10, 2014 · 2 comments
Closed
Labels

Comments

@sergeyfedotov
Copy link
Contributor

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
        )

    );
}
@linaori
Copy link
Contributor
linaori commented Dec 10, 2014

That's because the "add" is called most likely. That means that the submitted data is re-indexed. We solved this by using javascript to fix the index.

@sergeyfedotov
Copy link
Contributor Author

Duplicate of #7468

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants
0