How to hide message: The input was not found in the haystack in Zend Framework 2.5

Do you get this message "The input was not found in the haystack" in your Zend Framework form? A simple way to solve this error is to set the haystack for the validation in your form model.

Example:

$validator = new Zend\Validator\InArray(array('haystack' => array('value1', 'value2',...'valueN')));

You can also disable this validator. You can disable it by adding in your form model this code:

'options'=>array(
'disable_inarray_validator' => true
)

Your select box will be similar to this:

$this->add(array(
'type' => 'Zend\Form\Element\Select',
'name' => 'categories',
'attributes' => array(
'class'=>'form-control',
),
'options'=>array(
'disable_inarray_validator' => true
)
));









Leave a Comment