Skip to content

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

Closed
@murilolobato

Description

@murilolobato

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    DXFormhasPRA Pull Request has already been submitted for this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions