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

Categories

0 votes
343 views
in Technique[技术] by (71.8m points)

php - Zend form validation

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

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

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...