我使用 Zend\Form\Factory 在 zend framework2 中创建表单
$factory = new Zend\Form\Factory();
$factory->createForm(array(
'elements' => array(
array(
'spec' => array(
'name' => 'name',
),
),
),
'input_filter' => array(
'name' => array(
'validators' => array(
// validators for field "name"
),
'filters' => array(
// filters for field "name"
),
),
),
));
您可以看到字段“名称”有过滤器和验证器。有用。如果我使用字段集,我会遇到问题:
$factory->createForm(array(
'fieldsets' => array(
array(
'spec' => array(
'name' => 'common',
'elements' => array(
array(
'spec' => array(
'name' => 'name',
),
),
),
),
),
),
'input_filter' => array(
'name' => array(
'validators' => array(
// validators for field "name"
),
'filters' => array(
// filters for field "name"
),
),
),
));
在此示例中,输入过滤器不起作用。我不知道如何将过滤器和验证器设置为字段集“common”中的字段“name”
这个例子也不起作用:
$factory->createForm(array(
'fieldsets' => array(
array(
'spec' => array(
'name' => 'common',
'elements' => array(
array(
'spec' => array(
'name' => 'name',
),
),
),
'input_filter' => array(
'name' => array(
'validators' => array(
// validators for field "name"
),
'filters' => array(
// filters for field "name"
),
),
),
),
),
),
));