Skip to content

[Form] [DX] Collection of form with delete empty is not clear #7630

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
murilolobato opened this issue Mar 15, 2017 · 3 comments
Closed

[Form] [DX] Collection of form with delete empty is not clear #7630

murilolobato opened this issue Mar 15, 2017 · 3 comments
Labels
DX Form hasPR A Pull Request has already been submitted for this issue.
Milestone

Comments

@murilolobato
Copy link
Contributor

Instructions about delete_empty are partially ok. It instructs only that allow_delete must be enabled.

If you have a collection of another form type, and you want that empty items are deleted, you have to dig around the web (old issues and wrong workarounds), to discover that you just have to set entry_options => array('required' => false) at the collection definition.

I've discovered this searching in the issues. And found symfony/symfony#13940 which points to https://github.com/symfony/Form/blob/master/Tests/Extension/Core/Type/CollectionTypeTest.php#L145-166

I think, we could update the collection doc, in the section of delete_empty, to warn the developers about this behavior. And, why this entry_options => array('required' => false) makes sense? In my opinion, i think it is not legible. I'm available to help!

UPDATE
I have just found, why required => false makes sense. http://symfony.com/doc/2.8/reference/forms/types/form.html#empty-data

@murilolobato
Copy link
Contributor Author

Does anyone have a suggestion where to add instructions? I can make it, if you think it's wortwhile.

@HeahDude HeahDude added this to the 2.7 milestone Mar 26, 2017
@HeahDude
Copy link
Contributor

Hello @murilolobato thank you for working on this :). I think a caution block under the delete_empty option definition should do the trick.

@murilolobato
Copy link
Contributor Author

I've just made the pull request! #7767 thanks for help! Waiting for your suggestions.

@HeahDude HeahDude added the hasPR A Pull Request has already been submitted for this issue. label Apr 7, 2017
@xabbuh xabbuh closed this as completed Sep 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Form hasPR A Pull Request has already been submitted for this issue.
Projects
None yet
Development

No branches or pull requests

4 participants