Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to disable inArray validator forms in zend framework2

i use this in my Form:

$this->add(array(     
    'type' => 'Zend\Form\Element\Select',       
    'name' => 'county',
    'registerInArrayValidator' => false,
    'attributes' =>  array(
        'id' => 'county',                
        'options' => array(
            //'null'=>'[Select county]',
        ),
    ),
    'options' => array(
        'label' => 'county',
    ),
));

and set value county field with js. after validation, i get error : haystack option is mandatory

like image 896
Mohammad Mehdi Habibi Avatar asked Dec 16 '22 11:12

Mohammad Mehdi Habibi


2 Answers

Add the disable_inarray_validator to the options:

$this->add(array(
    ...
    'options' => array(
        'disable_inarray_validator' => true,
        'label' => 'county',
    ),
));
like image 131
Mohsen Reza Avatar answered Mar 03 '23 23:03

Mohsen Reza


In https://github.com/zendframework/zf2/blob/master/library/Zend/Form/Element/Select.php there is an option $disableInArrayValidator = false; and the corresponding method here

like image 43
MadeOfSport Avatar answered Mar 03 '23 22:03

MadeOfSport