1

I'm using select2 plugin so if I have the error on client side(html5) it shows me in a wrong position,because of the select2 plugin.(the position of the element)

I would like to disable html5 validation only for one specific element but leave the post validation.

$inputFilter = new InputFilter();   
 $this->add(array(
                'name' => 'supplierName',
                'type' => 'Text',
                'attributes' => array('id'=>'supplierName','required' => true)
            ));
$this->setInputFilter($inputFilter);
4

1 回答 1

1

禁用对表单定义的验证:

// 表单设置中的示例..

$this->add(array(
    'name' => 'fieldname',
    'attributes' => array(
        'type'  => 'text',
        'class' => 'something',
        'required'  => FALSE,
    ),
    'options' => array
          'label' => 'Some Field',
    ),
));

但在您的输入过滤器定义中启用它

// 输入过滤器设置中的示例 ..

$inputFilter->add($factory->createInput(array(
    'name'     => 'fieldname',
    'required' => TRUE,
    'filters'  => array(
        array('name' => 'Int'),
    ),
)));

表单定义将决定输入字段是否应用了所需的属性。

实际的输入过滤器决定在验证数据时是否需要它(发布或其他)

我相信这将允许在不使用任何客户端必需检查的情况下将该字段留空,但随后会检查以确保在执行输入过滤器验证检查时该字段是必需的。

于 2013-07-18T10:03:46.687 回答