入力フィルターを使用して複数選択を検証しようとしていますが、エラーが発生するたびに発生します。エラーは "notInArray":"The input was not found in the haystack" です (私は ajax を使用していますが、うまくいきません)。より明確にするために、コードの一部を示します。
コントローラーで:
if ($request->isPost()) {
$post = $request->getPost();
$form = new \Settings\Form\AddUserForm($roles);//
$form->get('positions')
->setOptions(
array('value_options'=> $post['positions']));
//.... more code...
print_r($post['positions']); を入れると なるほど: array(0 => 118, 1 => 119)
..../form/UserForm.php で乗算要素を作成します
$this->add(array(
'type' => 'Zend\Form\Element\Select',
'attributes' => array(
'multiple' => 'multiple',
'id' => 'choosed_positions',
),
'required' => false,
'name' => 'positions',
));
検証ファイルのコードは次のとおりです。
$inputFilter->add($factory->createInput(array(
'name' => 'positions',
'required' => false,
'validators' => array(
array(
'name' => 'InArray',
'options' => array(
'haystack' => array(118,119),
'messages' => array(
'notInArray' => 'Please select your position !'
),
),
),
),
毎回このエラーが表示される理由と、修正方法を教えてください。