0

is there any way to do complex forms with validation, for example:

Form with radio button with 2 choices A and B and field1,field2 and field3 required IF choice A is selected, and field4, field5 and field6 required IF choice B is selected?

1
  • 1
    Yes, you can use Callback constraints, or FormEvents on POST_SUBMIT to operates supplementary validation. Commented Aug 21, 2014 at 7:39

1 Answer 1

2

In order to generate client side control in real time (insert required="required" when necessary), I think the easiest way is to handle it with some Javascript event.

A FormEvent will not be sufficient to manage the user change (if the first radio change from A to B in your example).

For the "real" validation stuff, the best practice is to create your own class validator.

You can learn more about it here :

http://symfony.com/doc/current/cookbook/validation/custom_constraint.html#class-constraint-validator

Best regards.

Sign up to request clarification or add additional context in comments.

3 Comments

Symfony only handle server-side validation (something that you must implement always). Client validation made in JS is only for a better UX and/or UI
I am agree, that is why i oriented him to a symfony class validator (js is a bonus indeed ;) )
Thank you. That's what I need. I hoped to something more "ready" and built-in, but that's ok. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.