Skip to content

Disabling form validation: skipping the isValid() call does not supress the validation, contrary to what is stated in documentaion #2963

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
drscre opened this issue Sep 11, 2013 · 7 comments
Labels
actionable Clear and specific issues ready for anyone to take them. bug Form hasPR A Pull Request has already been submitted for this issue.

Comments

@drscre
Copy link

drscre commented Sep 11, 2013

The section
http://symfony.com/doc/current/book/forms.html#disabling-validation
states that

Sometimes it is useful to suppress the validation of a form altogether. For these cases,
you can skip the call to isValid() in your controller.

and

If you want to suppress validation completely, remove the isValid() call from your controller.

This does not work because form validation is performed in handleRequest()

@stof
Copy link
Member

stof commented Sep 12, 2013

Indeed, isValid does not perform the validation at all (this is done by a listener on POST_SUBMIT) but gives you the result

@xabbuh
Copy link
Member

xabbuh commented Sep 13, 2013

Is there any easy way to bypass the validation step that we can propose in the docs?

@wouterj
Copy link
Member

wouterj commented Sep 13, 2013

AFAICS, setting validation_group to false should do the trick.

@drscre
Copy link
Author

drscre commented Sep 13, 2013

With validation_groups = FALSE some basic integrity checks will still be performed (like presence of redundant data in POST, which sometimes can happen if you build a dynamic form where fields depend on each other and repaint it via ajax on value change)

@weaverryan
Copy link
Member

A little bit related to this, as of Symfony 2.3, the validation_groups option can be set on a button field. So that if you submit using this button, that validation group will be used. That doesn't help this issue, but it would be a nice note to add :).

I think the best thing to do is tell people about setting validation_groups to false. I don't think it's possible to disable the basic integrity checks as these are very fundamental to the way the forms system works. But, I'm also not sure what the use-case is for needing to completely disable validation (since you can always choose to show or not show the errors), so if the validation_groups solution is not good enough and someone has a use-case, tell us :).

  • Document setting validation_groups to false with a quick note in the forms chapter (see the original link above)

@xabbuh
Copy link
Member

xabbuh commented Dec 15, 2013

@weaverryan I would move the documentation of validation_groups on a button to a new issue. It is no directly related to this issue I think. But we can interlink both of course. What do you think?

@weaverryan
Copy link
Member

@xabbuh I agree! I've moved it to #3358

weaverryan added a commit that referenced this issue Dec 26, 2013
[#2963] Disabling validation corectly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable Clear and specific issues ready for anyone to take them. bug Form hasPR A Pull Request has already been submitted for this issue.
Projects
None yet
Development

No branches or pull requests

5 participants