Andrew
Andrew

Reputation: 6394

Zend: Form Validation After AJAX

I have a form done with Zend. I load it with ajax in a dialog. It has 2 selects. Depending on what is selected in the first select, it loads the content of the second one. However, when I submit the form I get a validation error because the options of the second form weren't there at the time of creating it.

Is there a way to fix this "issue"? It does what it needs to do but I don't want it to verify that field anymore. Any way to specify that I don't want that?

Upvotes: 0

Views: 241

Answers (1)

bububaba
bububaba

Reputation: 2870

You can disable the inArray validator. When constructing the form's select element, set

'registerInArrayValidator' => false

Also, a different solution would be to overload the isValid method, inspect the selected option for the first select element and then populate the options for the second element. Then call parent::isValid to check if the form is in fact valid or not.

Upvotes: 1

Related Questions