如何调整zend表单Radio元素的标签位置?
问题描述:
$feOnline = New Zend_Form_Element_Radio('online');
$feOnline->setValue($article->online)
->addMultiOptions(array(0=>'offline', 1=>'online'))
->setLabel('Online');
这个网站产生
<dd id="online-element">
<label for="online-0">
<input type="radio" checked="checked" value="0" id="online-0" name="online">offline
</label><br>
<label for="online-1"><input type="radio" value="1" id="online-1" name="online">online
</label>
</dd>
但是我不想标签标签内的输入标签。不需要“
”...
我必须添加哪些装饰器才能获得此输出?
<dd id="online-element">
<input type="radio" checked="checked" value="0" id="online-0" name="online"><label for="online-0">offline</label>
<input type="radio" value="1" id="online-1" name="online"><label for="online-1">online</label>
</dd>
答
如果您使用的是默认Zend_View_Helper_FormRadio
,则无法更改无线电的呈现方式。
代码如下(线159)
// Wrap the radios in labels
$radio = '<label'
. $this->_htmlAttribs($label_attribs) . ' for="' . $optId . '">'
. (('prepend' == $labelPlacement) ? $opt_label : '')
. '<input type="' . $this->_inputType . '"'
. ' name="' . $name . '"'
. ' id="' . $optId . '"'
. ' value="' . $this->view->escape($opt_value) . '"'
. $checked
. $disabled
. $this->_htmlAttribs($attribs)
. $endTag
. (('append' == $labelPlacement) ? $opt_label : '')
. '</label>';
没有配置在适当的位置改变逻辑。 想想你为什么REALLY需要改变它的呈现方式,请尝试使用CSS来设置输出样式。
如果您得出结论,您需要需要来更改渲染,创建您自己的视图助手并使用它而不是默认的助手。