I am using Zend Form to create dynamic form.
I have Zend Form validation too.
Trying to remove Validation dynamically, but not getting any success.
Can you plz help me to remove Zend Validation.
Bellow is my code for remove validation :
$toRemValArray = array();
$toRemValArray[0] = 'ele_4af42ceac7810';
if(isset($_POST['btnPost_x'])){
if ($form->isValid($_POST)) {
$allElements = $form->getElements();
foreach($allElements as $val){
if(in_array('ele_4af42ceac7810',$toRemValArray)){
$value = $form->getElement($val->getName());
$value->removeValidator('ele_4af42ceac7810');
}
}
}
}
Let me know whether my code is having any issue
Thanks Mohammad Tareque
You should remove the validator BEFORE calling $form->isValid().