Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable notInArray Validator Zend Framework 2

Is there a way to disable notInArray Validator in Zend Framework 2. All the info on the internet shows how to disable the notInArray Validator in Zend Framework 1, for example in this fashion

If you do not want the InArray validator at all, you can disable this behavior by either calling setRegisterInArrayValidator(false) on the element, or by passing false to the registerInArrayValidator configuration key on element creation.

One the posts in stackoverflow can be found here

Unfortunately this is not possible in Zend Framework 2. So in case if anybody has a tip how this can be disabled.

like image 311
user1686230 Avatar asked Nov 01 '12 09:11

user1686230


2 Answers

Since version 2.2, Zend Framework provide the ability to disable inArray validator calling:

$element->setDisableInArrayValidator(false);

or passing option to an element:

'disable_inarray_validator' => false
like image 96
tarkhov Avatar answered Oct 22 '22 13:10

tarkhov


I had the same problem and what i did is populate the element before validate it, for example:

$clientForm->get('city')->setValueOptions($options);
$clientForm->setData($post);

if ($clientForm->isValid()) {
  //
} else {
  //
}

This don't disable notInArray valitador but you can trick it.

like image 28
user1991158 Avatar answered Oct 22 '22 12:10

user1991158