Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
334 views
Welcome To Ask or Share your Answers For Others

1 Answer

You should remove the validator BEFORE calling $form->isValid().


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...