0
votes

I'm using Zend Form and the Jquery form validation plugin (http://bassistance.de/jquery-plugins/jquery-plugin-validation/). However, the plugin gets the required fields in the input tag. So for example, it locates "< input type='text' class='Required' id='anything' >" to perform the validate method. However, in Zend Form, when I use the setRequired(true) function, it places the "class='required'" inside the label portion. How do I resolve this?

PLUGIN < label >Hey< /label > < input type='text' class='Required' id='anything' > WORKS!

ZEND < label class='Required'>Sup < input type='text' id='anything' > DOES NOT WORK!

1
I think that jQuery data validation plugin can be restricting at times. I've had issues similar to this because it does a lot for you. I ended up writing my own Validation library that gives me more control while still producing custom errors. However, the DOM manipulation is left up to you. github.com/skaterdav85/Validator.jsskaterdav85
You already know the answer. Put it where the plugin needs it. Extra class inside the label will not interfere with the plugin.Sparky
Zend code is for "server-side" validation. jQuery code is for "client-side" validation. These are two different things so you cannot expect the settings for one to affect the other. Just give each method its required setups and both can work independently. Zend Validation will simply take over if/when jQuery Validation fails.Sparky

1 Answers

0
votes

You need something like this

$anything = new Zend_Form_Element_Text('anything');
$anything->setLabel('Label')
   ->setRequired(true)
   ->setAttrib('class', 'required');