Client-side validation for the new Symfony forms with jQuery
Posted on:Friday, January 23rd, 2009 by Hamid Palo- Download and install the jQuery validation plugin.
- Download the helper and put it in
lib/helper/jQueryValHelper.php - Include the jQueryVal helper.
- To enable the helper for a specific form:
<?php echo jquery_val_form_tag($form, array(‘action’ => url_for(“@register“) ))?>
That’s it.
The validator currently supports email, min and max length validation. The only required option is action, the other options you can pass it are:
error_placement: Change where the errors are rendered, for example:
'error_placement' => 'error.prependTo(element.parent().next())'error_element: Change the element used to render the errors, default is label.
All other options you pass are added to the form as attributes.

