-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Deprecated "cascade_validation" #12237
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
Conversation
Instead of removing that option I'd prefer it would be recursively passed properly to all children (as I expected from its name). That would make validation more failsafe when you don't need to remember adding the |
@craue cascade_validation was introduced s a way to reproduce the 2.0 behavior of the form validation. It is not intended to be the standard way of validating forms (which is why it is disabled by default). |
Why don't we think about validation by default all child entites? I think this is what you usually need. I acutally got used to cascade_validation since it is the way how it has been documented. http://symfony.com/doc/current/book/forms.html#embedding-a-single-object When docs will be updated this should be covered as well. |
In addition to that Assert\Valid() works differently compared to cascade_validation as discussed here: I think the way how cascade_validation works is actually what you would expect. There are cases where your child forms will have validation groups based on there state so you should not add this to the parent form. Or what do you recommend in regard to this? |
I would say if this is changed the validation_groups of the child forms should be respected accordingly as with the cascade_validation setting. I would assume moving all people from cascade_validation to Assert\Valid() and not providing a solution for the validation_groups setting to have validation groups based on the entity state would lead to many issues. Or we add another logic and tie the logic to the entity as we started to discuss here #11880. |
@craue As I mentioned in the ticket description, there's almost no valid use case to use "cascade_validation". Use the Valid constraint, always. @peterrehm This is in fact a documentation issue. I opened a new ticket there: symfony/symfony-docs#4346
That's the correct approach to solve the problem IMO. |
Is there anything else affected rather than the validation_groups setting of the form? |
I'm not sure that's a good idea, but it's an option. |
But if not deprecated (I don't know as well if it is a good idea) I think we should consider cascading them as cascade_validation does. |
…ed forms to Valid... (peterrehm) This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #4348). Discussion ---------- Updated information about handling validation of embedded forms to Valid... | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | all | Fixed tickets | #4346 Applied Valid constraint instead of the cascade_validation option since this option is supposed to be deprecated with symfony/symfony#12237 Commits ------- b699731 Updated information about handling validation of embedded forms to Valid constraint
ping @symfony/deciders |
@webmozart what is that 1%? |
@webmozart this PR should probably be sent again with the 2.7 branch as target (and rebased) so that tests can run (Travis is currently not working on 3.0.x-dev even if you rebase). I would like to see #11268 fixed as it is a nasty bug. |
Any progress on that one? |
@Tobion The use case when you have a subform with an object that is not referred to from the parent form's object (so |
…imler) This PR was merged into the 2.8 branch. Discussion ---------- fix Merge branch '2.7' into 2.8 JsonFileLoader This fix a merge commit see symfony@5593bdd. The `stream_is_local` and `file_exists` checks are all ready done in the parent `FileLoader` class. | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | no | Fixed tickets | none | License | MIT | Doc PR | none Commits ------- 692deff fix Merge branch '2.7' into 2.8 JsonFileLoader
This PR was merged into the 2.8 branch. Discussion ---------- [Profiler][Translation] added filter. | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Fixed tickets | ~ | Tests pass? | yes | License | MIT  Commits ------- 65f9291 [Profiler][Translation] added filter.
This PR was submitted for the master branch but it was merged into the 2.8 branch instead (closes symfony#12067). Discussion ---------- [Form] Added the 'range' FormType | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#11979 | License | MIT | Doc PR | Implemented the "range" FormType. Commits ------- b52e197 [Form] Added the 'range' FormType
a21072b
to
d85c817
Compare
Replaced by #15019. |
This PR was merged into the 2.8 branch. Discussion ---------- [Form] Deprecated "cascade_validation" | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #11268 (requires explicit work though) | License | MIT | Doc PR | TODO This is #12237 rebased on 2.8. The "cascade_validation" option was designed for a 1% use case and comparatively used way too often when the `Valid` constraint should have been used instead. Also, there seem to be bugs with that option (#5204). The option is now deprecated. When using the 2.5 Validator API, you can set the "constraints" option of the respective child to a `Valid` constraint instead. Alternatively, set the constraint in the model (as most people hopefully do). Commits ------- 6c554c6 [Form] Deprecated "cascade_validation"
…n constraint (peterrehm) This PR was submitted for the master branch but it was merged into the 2.8 branch instead (closes #4354). Discussion ---------- [WCM] Added depreciation note for the cascade_validation constraint | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | 2.8 | Fixed tickets | - This PR was based on symfony/symfony#12237 and has been updated based as symfony/symfony#15019. #4348 Commits ------- 22a87b5 Added depreciation note for the cascade_validation constraint and updated position of depreciation notes
The "cascade_validation" option was designed for a 1% use case and comparatively used way too often when the
Valid
constraint should have been used instead. Also, there seem to be bugs with that option (#5204).The option is now deprecated. When using the 2.5 Validator API, you can set the "constraints" option of the respective child to a
Valid
constraint instead. Alternatively, set the constraint in the model (as most people hopefully do).