开发者

Zend Form Field set Validator to invalid

开发者 https://www.devze.com 2023-03-15 01:38 出处:网络
How to set Form Field to invalid from controller? Example: $form->getElement(\'name\')->set.... Validator to FALSE开发者_如何学C

How to set Form Field to invalid from controller?

Example:

$form->getElement('name')->set.... Validator to FALSE开发者_如何学C

or something similar???

Part of code:

    if(....){
    $form->getSubForm('sub_form_name')->getElement('element_name')->addError('some error message');
    }


    if($form->isValid($this->getRequest()->getPost())) {
//Form is going to be valid and execute this statment
    }

i try too with: markAsError() and hasError(); but not working :(


If you use any of the addError...() or setError...() on your element it should set the validation flag to invalid, or so the documentation says

Zend_Form_Element.addError(string $message)

Add an error message and mark element as failed validation


A litle POGramation. :) Not the best way, but works fine.

            $vazio = false;
        if(is_array($nomes)){
      $vazio = true; 
              $form->addError("NomeIsArray");
        }

        if(!$vazio && $form->isValid($post)){

            }
0

精彩评论

暂无评论...
验证码 换一张
取 消