I created a form with Zend_Form adding 2 select boxes. One where all the states would be shown and  after selecting a state, it had to update a second select box with all the cities corresponding to the chosen state.

After I had build the form, I created the javascript code (JQuery) to get all the cities corresponding to the selected value of the states select box.

Now when I tried to submit the form, the validation on the form failed.
This was because Zend_Form automatically validates the submited values with the original values added to the select boxes.

Solution:
//cities is our select box created with Zend_Form_Element_Select
$cities->setRegisterInArrayValidator(false);

The validation on the select box ‘cities’ is turned off and you will be able to submit the form.


No Tags