How to remove a validator from a Form Element / Form Element ValidatorChain in Zend Framework 2?

前端 未结 2 1579
一整个雨季
一整个雨季 2021-01-06 07:33

I read this question on SO: \"how to disable inArray validator forms in zend framework2\" and was trying to find it out, but couldn\'t find any way to detach/remove the

2条回答
  •  旧时难觅i
    2021-01-06 07:44

    I found this to work with 1.12.3

    in my update form

    $element = new My_Form_Element_Username('username');
    $element->setValue('some-value');
    $element->removeValidator('Db_NoRecordExists');
    $this->addElement($element);
    

    or

    $this->addElement(new My_Form_Element_Username('username')
      ->setValue('some-value')
      ->removeValidator('Db_NoRecordExists');
    

    My_Form_Element_Username just extends some Zend_Form_Element and has the validators defined.

提交回复
热议问题