Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Closed

Conversation

webmozart
Copy link
Contributor

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

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).

@craue
Copy link
Contributor

craue commented Oct 16, 2014

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 Valid constraint everywhere. When I validate something, I expect that even data in child forms is validated, so I had to generally set cascade_validation in all my forms, but sometimes got hit by #5204 and had to add an additional Valid constraint to make validation work properly. Thus 👎 from me.

@stof
Copy link
Member

stof commented Oct 16, 2014

@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).

@peterrehm
Copy link
Contributor

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.

@peterrehm
Copy link
Contributor

In addition to that Assert\Valid() works differently compared to cascade_validation as discussed here:

#9650 (comment)

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?

@peterrehm
Copy link
Contributor

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.

@webmozart
Copy link
Contributor Author

@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

Or we add another logic and tie the logic to the entity as we started to discuss here #11880.

That's the correct approach to solve the problem IMO.

@peterrehm
Copy link
Contributor

Is there anything else affected rather than the validation_groups setting of the form?
How about deprecating the validation_groups setting as well when we find a solution for #11880.
I will try to reply to you later today or tomorrow.

@webmozart
Copy link
Contributor Author

How about deprecating the validation_groups setting as well when we find a solution for #11880.

I'm not sure that's a good idea, but it's an option.

@peterrehm
Copy link
Contributor

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.

@webmozart webmozart added the Form label Oct 22, 2014
weaverryan added a commit to symfony/symfony-docs that referenced this pull request Oct 29, 2014
…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
@webmozart
Copy link
Contributor Author

ping @symfony/deciders

@Tobion
Copy link
Contributor

Tobion commented Nov 3, 2014

The "cascade_validation" option was designed for a 1% use case

@webmozart what is that 1%?

@stof
Copy link
Member

stof commented Nov 21, 2014

@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.

@peterrehm
Copy link
Contributor

Any progress on that one?

@webmozart
Copy link
Contributor Author

@Tobion The use case when you have a subform with an object that is not referred to from the parent form's object (so @Valid can't be used). In practice, this rarely happens.

gimler and others added 6 commits June 11, 2015 21:27
…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

![selection_017](https://cloud.githubusercontent.com/assets/1753742/8159914/c2c8ad68-135a-11e5-9ae3-f2e055ea3230.jpg)

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
@webmozart
Copy link
Contributor Author

Replaced by #15019.

fabpot added a commit that referenced this pull request Jun 17, 2015
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"
weaverryan added a commit to symfony/symfony-docs that referenced this pull request Jun 19, 2015
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants