小编Adr*_*cki的帖子

过滤器和验证器将添加两次

我在zf2 github写过这篇文章但还没有人回答.但也许这不是一个错误,我做错了什么.这是我的代码:

字段集

class TestFieldset extends Fieldset implements
    InputFilterProviderInterface
{
    public function __construct($name)
    {
        parent::__construct($name);

        $this->add(array(
            'type' => 'text',
            'name' => 'test'
        ));
    }

    public function getInputFilterSpecification() {
        return array(
            'test' => array(
                'filters' => array(
                    array('name' => 'StringTrim')
                ),
                'validators' => array(
                    array('name' => 'NotEmpty')
                )
            )
        );
    } 
}
Run Code Online (Sandbox Code Playgroud)

形成

class TestForm extends Form
{
    public function __construct($name = null, $options = array()) {
        parent::__construct($name, $options);

        $fieldset = new TestFieldset('test-fieldset');

        $this->add($fieldset);
    }
}
Run Code Online (Sandbox Code Playgroud)

控制器动作 …

php zend-framework2 zend-form2

5
推荐指数
1
解决办法
237
查看次数

标签 统计

php ×1

zend-form2 ×1

zend-framework2 ×1