开发者

Zend Form Field set Validator to invalid

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜