以下示例是我对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'),
));
但为什么我需要这个空键?!