我想添加没有标签的输入, 我想拥有像这个流程的HTML代码
<label>sender</label>
<input type="text" name="senderNo"/>
<input type="text" name="senderName"/>
我做装饰
$mailSenderNo = new Zend_Form_Element_Text('mailSenderNo');
$mailSenderNo->setLabel("الجهة المرسلة")
->setDecorators(
$this->setInlineDecorator("smallNoText")
);
$mailSenderName = new Zend_Form_Element_Text('mailSenderName');
$mailSenderName->setDecorators(
$this->setInlineDecorator("largeText")
);
这是装饰者
function setInlineDecorator($className = null) {
$inlineDecorator = null;
if ($className == null) {
$inlineDecorator = array(
'ViewHelper',
'Errors',
array(array('data' => 'HtmlTag'), array('tag' => 'span')),
array('Label', array('tag' => 'span', 'class' => 'elementTitle'))
);
} else {
$inlineDecorator = array(
'ViewHelper',
'Errors',
array(array('data' => 'HtmlTag'), array('tag' => 'span','class' => $className)),
array('Label', array('tag' => 'span' ))
);
}
return $inlineDecorator;
}
此结果
<span id="mailSenderNo-label">
<label class="optional" for="mailSenderNo">الجهة المرسلة</label>
</span>
<span class="smallNoText">
<input id="mailSenderNo" type="text" value="" name="mailSenderNo">
</span>
<span id="mailSenderName-label"> </span> ????? I don't what to have this span
<span class="largeText">
<input id="mailSenderName" type="text" value="" name="mailSenderName">
</span>
此跨度
<span id="mailSenderName-label"> </span>
用于mailSenderName输入的标签,如何删除此span ????
答案 0 :(得分:3)
添加以下行: -
$mailSenderName->removeDecorator('Label');
这将仅从该元素中删除标签。