如何在zend framework2中禁用inArray验证器表单 [英] how to disable inArray validator forms in zend framework2

查看:175
本文介绍了如何在zend framework2中禁用inArray验证器表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  $ this-> add(array(
'type' =>'Zend\Form\Element\Select',
'name'=>'county',
'registerInArrayValidator'=> false,
'attributes'= > array(
'id'=>'county',
'options'=>数组(
//'null'=>'[Select county]',
),
),
'options'=>数组(
'label'=>'county',
),
));

并用js设置值县字段。
验证后,我得到错误:haystack选项是强制性的

解决方案

将disable_inarray_validator添加到选项中:

  $ this-> add(array(
...
'options'=> array(
'disable_inarray_validator'=> true,
'label'=>'county',
),
));


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

解决方案

Add the disable_inarray_validator to the options:

$this->add(array(
    ...
    'options' => array(
        'disable_inarray_validator' => true,
        'label' => 'county',
    ),
));

这篇关于如何在zend framework2中禁用inArray验证器表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆