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
registerInArrayValidatoronly works for the ZF1. I would formulate the question a some abstractlier: How to remove a validator from the Form ElementValidatorChain? Have been debugging a bit and can actually not find and way to do this. Maybe somehow over theValidatorPluginManager($form->getInputFilter()->get('myElement')->getValidatorChain()>getPluginManager())...Selectclass and adding a new methodsetInarray(...). Don't know iwhether it works, but you could try it out.$formInputFilter = $form->getInputFilter(); $formInputFilter->remove('county'); $formInputFilter->add((new Zend\InputFilter\Factory())->createInput(array( 'name' => 'county', 'required' => true, )));See my question and Remi Thomas's comment. But for me it's a workaround, not a solution, I would be happy with.