title: How to validate multiply select using Zend Framework 2
body: <p>I am trying to validate a multiply select using input filter, but every time I see a error. The error is "notInArray":"The input was not found in the haystack".(I use ajax but it doesn`t metter).
  I will show part of my code to be more clear.</p>
  
  <p>in Controller:
  <code></p>
  
  <pre><code>if ($request-&gt;isPost()) {
              $post = $request-&gt;getPost();
              $form = new \Settings\Form\AddUserForm($roles);// 
              $form-&gt;get('positions')
                           -&gt;setOptions(
                                   array('value_options'=&gt; $post['positions']));
  </code></pre>
  
  <p>//.... more code...
  </code></p>
  
  <p>When I put print_r($post['positions']); I see:
  array(0 => 118, 1 => 119)</p>
  
  <p>in ..../form/UserForm.php I create the multiply element</p>
  
  <pre><code>$this-&gt;add(array(
                  'type' =&gt; 'Zend\Form\Element\Select',
                  'attributes' =&gt; array(
                      'multiple' =&gt; 'multiple',
                      'id' =&gt; 'choosed_positions',
                  ),
                  'required' =&gt; false,
                  'name' =&gt; 'positions',
  
  
  
          ));
  </code></pre>
  
  <p>and in the validation file the code is:</p>
  
  <pre><code>$inputFilter-&gt;add($factory-&gt;createInput(array(
                          'name' =&gt; 'positions',
                          'required' =&gt; false,
                          'validators' =&gt; array(
                              array(
                                  'name' =&gt; 'InArray',
                                   'options' =&gt; array(
                                      'haystack' =&gt; array(118,119),
                                      'messages' =&gt; array(
                                          'notInArray' =&gt; 'Please select your position !'
                                      ),
                                  ),
                              ),
                          ),
  </code></pre>
  
  <p>What can be the reason every time to see this error, and how I can fix it?</p>