小编Ada*_*mon的帖子

Zend_Form数组表示法和空元素名称

我想渲染:

<input type="text" value="" name="foo[]" />
<input type="text" value="" name="bar[]" />
Run Code Online (Sandbox Code Playgroud)

但是Zend_Form_Element需要一个(字符串)名称,所以我需要这样做:

$this->addElement('text', '1', array(
    'belongsTo' => 'foo'
));

$this->addElement('text', '2', array(
    'belongsTo' => 'bar'
));
Run Code Online (Sandbox Code Playgroud)

但输出是:

<input id="foo-1" type="text" value="" name="foo[1]" />
<input id="bar-2"  type="text" value="" name="bar[2]" />
Run Code Online (Sandbox Code Playgroud)

我也可以接受如下输出:

<input id="foo-1" type="text" value="" name="foo[1]" />
<input id="bar-1"  type="text" value="" name="bar[1]" />
Run Code Online (Sandbox Code Playgroud)

但Zend_Form_Element重写了同名的元素

有办法做我需要的吗?

zend-form zend-form-sub-form

5
推荐指数
1
解决办法
4293
查看次数

标签 统计

zend-form ×1

zend-form-sub-form ×1