Zend framework Zend复选框装饰器问题
您好,我正在尝试进行复选框显示,如:Zend framework Zend复选框装饰器问题,zend-framework,checkbox,zend-form,Zend Framework,Checkbox,Zend Form,您好,我正在尝试进行复选框显示,如: <input name="choice2" id="choice2" value="1" type="checkbox"> <label for="choice2" class="optional">Credit Card</label><br /> Some text <input name="choice2" id="choice2" value="1" type="checkbox"> &l
<input name="choice2" id="choice2" value="1" type="checkbox">
<label for="choice2" class="optional">Credit Card</label><br />
Some text
<input name="choice2" id="choice2" value="1" type="checkbox">
<label for="choice2" class="optional">Credit Card</label><br />
Some text
信用卡
一些文本
信用卡
一些文本
我非常熟悉以下代码:
$lbl_spagym = 'Credit Card<br />
<p class="description">Some text</p><br />';
$chk_spagym = new Zend_Form_Element_Checkbox('chk_spagym');
$chk_spagym->setLabel($lbl_spagym)
->setDecorators(array(
'ViewHelper',
'Description',
'Errors',
array('Label', array('placement' => 'APPEND', 'escape' => false)),
array('HtmlTag', array('tag' => 'div'))
));
$lbl\u spagym='信用卡
一些文本;
$chk_spagym=新的Zend_表单元素复选框('chk_spagym');
$chk_spagym->setLabel($lbl_spagym)
->setDecorators(数组)(
“ViewHelper”,
“说明”,
“错误”,
数组('Label',数组('placement'=>'APPEND','escape'=>false)),
数组('HtmlTag',数组('tag'=>'div'))
));
它呈现为:
<div>
<input type="hidden" name="chk_bank" value="0" />
<input type="checkbox" name="chk_bank" id="chk_bank" value="1" checked="checked" />
<label for="chk_bank" class="optional">Credit Card<br />
<p class="relocation_descr">Some text</p><br />
</label></div>
信用卡
一些文本
但是我需要将
从标签标签中删除,因为“some text”是一个描述而不是标签。我和装饰师玩了好几天,但都没能纠正这种行为。如果您对此有任何评论,我们将不胜感激。您应该能够使用以下内容创建该标记
$form->addElement('checkbox', 'choice2', array(
'label' => 'Credit Card',
'decorators' => array(
'ViewHelper',
array('Label', array('placement' => 'append',
'class' => 'optional'))
)
));
这将为复选框“off”值生成一个隐藏元素,但请相信我,您希望保留该元素。我将问题归结为:
$checkbox_e->setLabel($e_label)
->setDecorators(array('ViewHelper',
'Description',
'Errors',
array('Label',
array('placement'=>'APPEND')),
array('HtmlTag', array('tag' => 'div'))));
但那不是我真正需要的。我刚刚重新表述了我的问题。StackOverflow不是一个论坛,而是一个问答网站。如果您有其他信息要添加到原始问题中,请编辑您的原始帖子。