【发布时间】:2014-02-27 07:52:58
【问题描述】:
我在表单中设置了一个字段集(集合),我希望允许添加和删除元素。所以,我的代码是:
$hydrator = new Hydrator($this->getObjectManager(), 'Base\Entity\MyElements');
$fieldset = new MyElements();
$fieldset->setObjectManager($this->getObjectManager())
->setHydrator($hydrator)
->setObject(new \Base\Entity\MyElements())
->init();
$this->add(array(
'type' => 'Zend\Form\Element\Collection',
'name' => 'myElements',
'options' => array(
'label' => 'My Elements',
'count' => 1,
'should_create_template' => true,
'allow_add' => true,
'allow_remove' => true,
'target_element' => $fieldset
)
));
我可以添加元素,但是没有出现删除按钮。我做错了还是忘记了什么?
PS:我的英语很差,但我正在努力提高它。对不起。谢谢
【问题讨论】:
标签: php collections zend-framework2