ZF2子输入过滤器

时间:2013-01-31 17:00:56

标签: zend-framework2 zend-inputfilter

以下示例是我对subfiltering的主要问题。我不明白为什么键必须是一个空字符串。

    $filter = new \Zend\InputFilter\InputFilter();

    $filter->add(array(
        'type' => 'Zend\InputFilter\InputFilter',
        'password' => array(
            'name' => 'password',
            'required' => true,
            'validators' => array(
                array(
                    'name' => 'not_empty',
                ),
            ),
        ),
    ));

    $filter->setData(array(
        array('password' => '123'),
    ));

    $filter->IsValid();

    var_dump($filter->getMessages());

输出:

     array (size=1)
          '' => 
            array (size=1)
              'password' => 
                array (size=1)
                  'isEmpty' => string 'Value is required and can't be empty' (length=36)

使用

    $filter->setData(array(
        '' => array('password' => '123'),
    ));

但为什么我需要这个空键?!

0 个答案:

没有答案