-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] delete_empty don't work for embedded forms without data_class #22008
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
Comments
Maybe @peterrehm or @cordoval could help, as they're involved at the creation of delete_empty. |
@murilolobato if Could you try with Edit: The documentation talks about this too |
@yceruto I've updated the pull request, now with the allow_delete to my test. It still fails, I already knew that it would fail too, beacuse in my real app I've made a bunch of tests and tentatives. And you touched a nice point, because the test I wrote is a copy from the test above, and in that test there is no allow_delete, but works... |
Well, I see that, still with |
Maybe related to #13601? @murilolobato could the approach of #20496 solve your problem? |
In #13601, I think that the functionality proposed by @Koc is not needed in that usecase. But maybe, this functionality could help me, because I would teach to the form how to determine if a item is empty, and if it is empty it would be removed from the collection and everything would work, in theory. The question that @yceruto made in the pull request is very convenient too, it is worth to take a look. |
Closing in favor of #13601 |
…on. (Koc) This PR was merged into the 3.4 branch. Discussion ---------- [Form] Allow pass filter callback to delete_empty option. | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #13601, #13940, #22008, #22014 | License | MIT | Doc PR | coming soon Commits ------- 8630abe [Form] Allow pass filter callback to delete_empty option.
I'm creating a form, that has a collection of another form. OrderType has a collection of ItemType. Assuming that both have the option
data_class = null
, empty items are not being removed during form submit. Empty Items are being validated. The expected behavior was that empty items would be removed, as it happens when I create entities for this two types and set them in type'sdata_class
options.Looking at the source code and other issues, people already have had problem with delete_empty, but this is a new case. I've also found the tests to
delete_empty
and the scenario I've listed above is not being tested.Here is the test with data_class defined: https://github.com/symfony/Form/blob/master/Tests/Extension/Core/Type/CollectionTypeTest.php#L145
I'll try to create a test, and attach to this issue, but I can't promise anything.
The text was updated successfully, but these errors were encountered: