【发布时间】:2010-08-03 14:25:57
【问题描述】:
我有两个表单,它们共享一些 ID,因为两个输入字段称为“标题”。
Zend 为我生成了一个不错的输出,如下所示:
<dl class="zend-form">
<dt id="title-label">
<label for="form1-title" class="required">Description</label>
</dt>
<dd id="title-element">
<input name="form1[title]" id="form1-title" value="..." type="text">
</dd>
</dl>
现在的问题是 dt 和 dd 元素命名错误(应该是 form1-title-lable 因为这是一个子表单)。
我也尝试改变元素装饰器:
$this->addElements( ... );
$this->setElementDecorators(array(
'ViewHelper',
'Errors',
array(array('data' => 'HtmlTag'),array( 'tag' => 'dd', 'class' => 'element' )),
array(array('data' => 'Label'),array( 'tag' => 'dt', class=> 'label' ))
));
然而结果并不如预期。
一个标签被添加到我的提交按钮和 dt 元素的 id 仍然存在。
如何移除 id 属性?
编辑 - 元素声明:
$titel = new Zend_Form_Element_Text('title');
$titel->setLabel( "Title" )
->addValidator('NotEmpty', true)
->addValidator('stringLength',true, array(0, 255 ))
->setRequired(true)
->addFilter("Alnum", array(true))
->addFilter('StringTrim');
$this->addElement($titel);
【问题讨论】:
-
你在使用子表单吗?你能发布这个元素的整个代码吗?
标签: php zend-framework zend-form zend-decorators