[Form] Forms now don't create empty objects anymore if they are empty and not required#3257
Merged
fabpot merged 1 commit intosymfony:masterfrom Feb 2, 2012
Merged
Conversation
…etely empty and not required. The empty data for these forms is null.
Contributor
Author
There was a problem hiding this comment.
No typo. It's bound empty (without data) while the form has no (empty) data. It's slightly confusing, I agree.
Contributor
There was a problem hiding this comment.
I see. The other test names also confused me. I think it would be more clear with on preposition.
So testBindEmptyDataOnEmptyDataCreatesNoObjectIfNotRequired and testBindOnEmptyDataCreatesObjectIfClassAvailable.
fabpot
added a commit
that referenced
this pull request
Feb 2, 2012
Commits ------- bd461e2 [Form] Forms now don't create empty objects anymore if they are completely empty and not required. The empty data for these forms is null. Discussion ---------- [Form] Forms now don't create empty objects anymore if they are empty and not required Bug fix: yes Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes Fixes the following tickets: #2861 Todo: -  If a form (or a nested form) is left completely empty upon submission and is not required, no new data object will be generated anymore. Instead, the form returns null as data.
fabpot
added a commit
that referenced
this pull request
Dec 17, 2013
…ata handling of collections (peterrehm) This PR was squashed before being merged into the 2.5-dev branch (closes #9773). Discussion ---------- [Form] Added delete_empty option to allow proper emptyData handling of collections | Q | A | ------------- | --- | Bug fix? | yes | New feature? | yes/no? | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #9375 | License | MIT | Doc PR | symfony/symfony-docs#3338 This PR adresses the issue that if you have a form collection with the option required => false and you submit an empty collection so you will get a ArrayCollection that contains en element with the value null. This behaviour was introduced with the following changes from #3257 In addition to the above mentioned ticket there is also a description about the same issue here: http://stackoverflow.com/questions/19474872/symfony2-form-collection-allow-add-and-allow-delete-null-error-silex With the changes of this PR the new option empty_data is introduced. With this option you will be able to ignore/delete such empty collections, so they will neither be validated nor appear as empty field in the result. The option will remove/ignore such empty collections if you add them newly and if allow_add is enabled and removes such empty collections only if allow_delete is enabled. With setting required and empty_data accordingly it will be now flexible to customize to the outcome you want to achieve. Thanks to @bschussek for the great work together - We have to discuss how to name this option so if delete or ignore is the appropriate name. Commits ------- 8bdb7a0 [Form] Added delete_empty option to allow proper emptyData handling of collections
fabpot
added a commit
to symfony/form
that referenced
this pull request
Dec 17, 2013
…ata handling of collections (peterrehm) This PR was squashed before being merged into the 2.5-dev branch (closes #9773). Discussion ---------- [Form] Added delete_empty option to allow proper emptyData handling of collections | Q | A | ------------- | --- | Bug fix? | yes | New feature? | yes/no? | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #9375 | License | MIT | Doc PR | symfony/symfony-docs#3338 This PR adresses the issue that if you have a form collection with the option required => false and you submit an empty collection so you will get a ArrayCollection that contains en element with the value null. This behaviour was introduced with the following changes from symfony/symfony#3257 In addition to the above mentioned ticket there is also a description about the same issue here: http://stackoverflow.com/questions/19474872/symfony2-form-collection-allow-add-and-allow-delete-null-error-silex With the changes of this PR the new option empty_data is introduced. With this option you will be able to ignore/delete such empty collections, so they will neither be validated nor appear as empty field in the result. The option will remove/ignore such empty collections if you add them newly and if allow_add is enabled and removes such empty collections only if allow_delete is enabled. With setting required and empty_data accordingly it will be now flexible to customize to the outcome you want to achieve. Thanks to @bschussek for the great work together - We have to discuss how to name this option so if delete or ignore is the appropriate name. Commits ------- 8bdb7a0 [Form] Added delete_empty option to allow proper emptyData handling of collections
fabpot
added a commit
to symfony/form
that referenced
this pull request
Mar 30, 2014
…ata handling of collections (peterrehm) This PR was squashed before being merged into the 2.5-dev branch (closes #9773). Discussion ---------- [Form] Added delete_empty option to allow proper emptyData handling of collections | Q | A | ------------- | --- | Bug fix? | yes | New feature? | yes/no? | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #9375 | License | MIT | Doc PR | symfony/symfony-docs#3338 This PR adresses the issue that if you have a form collection with the option required => false and you submit an empty collection so you will get a ArrayCollection that contains en element with the value null. This behaviour was introduced with the following changes from symfony/symfony#3257 In addition to the above mentioned ticket there is also a description about the same issue here: http://stackoverflow.com/questions/19474872/symfony2-form-collection-allow-add-and-allow-delete-null-error-silex With the changes of this PR the new option empty_data is introduced. With this option you will be able to ignore/delete such empty collections, so they will neither be validated nor appear as empty field in the result. The option will remove/ignore such empty collections if you add them newly and if allow_add is enabled and removes such empty collections only if allow_delete is enabled. With setting required and empty_data accordingly it will be now flexible to customize to the outcome you want to achieve. Thanks to @bschussek for the great work together - We have to discuss how to name this option so if delete or ignore is the appropriate name. Commits ------- 8bdb7a0 [Form] Added delete_empty option to allow proper emptyData handling of collections
fabpot
added a commit
to symfony/form
that referenced
this pull request
May 23, 2014
…ata handling of collections (peterrehm) This PR was squashed before being merged into the 2.5-dev branch (closes #9773). Discussion ---------- [Form] Added delete_empty option to allow proper emptyData handling of collections | Q | A | ------------- | --- | Bug fix? | yes | New feature? | yes/no? | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #9375 | License | MIT | Doc PR | symfony/symfony-docs#3338 This PR adresses the issue that if you have a form collection with the option required => false and you submit an empty collection so you will get a ArrayCollection that contains en element with the value null. This behaviour was introduced with the following changes from symfony/symfony#3257 In addition to the above mentioned ticket there is also a description about the same issue here: http://stackoverflow.com/questions/19474872/symfony2-form-collection-allow-add-and-allow-delete-null-error-silex With the changes of this PR the new option empty_data is introduced. With this option you will be able to ignore/delete such empty collections, so they will neither be validated nor appear as empty field in the result. The option will remove/ignore such empty collections if you add them newly and if allow_add is enabled and removes such empty collections only if allow_delete is enabled. With setting required and empty_data accordingly it will be now flexible to customize to the outcome you want to achieve. Thanks to @bschussek for the great work together - We have to discuss how to name this option so if delete or ignore is the appropriate name. Commits ------- 8bdb7a0 [Form] Added delete_empty option to allow proper emptyData handling of collections
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #2861
Todo: -
If a form (or a nested form) is left completely empty upon submission and is not required, no new data object will be generated anymore. Instead, the form returns null as data.