Skip to content
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

validation_groups can be a closure #22

Closed
toooni opened this issue Aug 31, 2012 · 9 comments
Closed

validation_groups can be a closure #22

toooni opened this issue Aug 31, 2012 · 9 comments

Comments

@toooni
Copy link

toooni commented Aug 31, 2012

since Symfony 2.1 the validation_groups of the form view can be closures (http://symfony.com/doc/master/book/forms.html#groups-based-on-submitted-data).
It would be nice if the APYJsFormValidationBundle can be used with them too... at the moment there is thrown an error as followed:

An exception has been thrown during the rendering of a template ("Warning: in_array() expects parameter 2 to be array, object given in .../vendor/apy/jsfv-bundle/APY/JsFormValidationBundle/EventListener/ValidationGroupsListener.php line 35") in The Bundle::template.html.twig at line xx.

@Abhoryo
Copy link
Owner

Abhoryo commented Aug 31, 2012

Ok.

@Abhoryo
Copy link
Owner

Abhoryo commented Aug 31, 2012

For now I don't have access to the form to do this.

@toooni
Copy link
Author

toooni commented Aug 31, 2012

i just looked a bit into it and maybe it isn't possible to realize something like this in a simple way :S

@Abhoryo
Copy link
Owner

Abhoryo commented Aug 31, 2012

The closure for the validation_group needs a Form object but we have only the FormView object.

If your code doesn't need this form object in the closure, we can pass a fake Form object.

@recipe
Copy link

recipe commented Aug 31, 2012

The problem is not misrepresented that the form is not available but that closure is called on form post-bind event.
We generate client-side javascript using any available information which can be retrieved before the form is rendered.

@toooni
Copy link
Author

toooni commented Aug 31, 2012

yes.. so there is no simple way.. the "form object" is what is needed inside the closure.. else it doesn't make sense to have one..
the only (very complex) solution is to use ajax calls for this.. client-side validation using closures in validation_groups is impossible..

@recipe
Copy link

recipe commented Aug 31, 2012

First of all we should fix code to avoid error messages. After that, you'll be able at least use custom js code.

@recipe
Copy link

recipe commented Aug 31, 2012

In this bundle validation_groups is used only for filtering the fields, that should not be checked.

recipe pushed a commit that referenced this issue Aug 31, 2012
@Abhoryo
Copy link
Owner

Abhoryo commented Sep 3, 2012

Are we close this issue ?

@toooni toooni closed this as completed Sep 3, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants