使用 Zend_Form,我将如何创建这样的表单元素:
Using Zend_Form, how would I create form elements like this:
<input type="text" name="element[1]" value="" />
<input type="text" name="element[2]" value="" />
// etc...
您可以使用子表单:
$form = new Zend_Form();
$subForm = new Zend_Form_SubForm();
$subForm->addElement('Text', '1')
->addElement('Text', '2');
$form->addSubForm($subForm, 'element');
或者你也应该能够在表单元素上使用 setBelongsTo()
(未经测试):
Or you should also be able to use setBelongsTo()
on the form elements (untested):
$form = new Zend_Form();
$form->addElement('Text', '1', array('belongsTo' => 'element'))
->addElement('Text', '2', array('belongsTo' => 'element'));
这篇关于Zend_Form - 基于数组的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!