我需要设置要打印的装饰:
<input type="radio" id="option1" name="option" value="foo">
<label for="option1"></label>
<label>Option 1</label>使用Zend_Form_Element_Radio。
我试过了:
$pass = new Zend_Form_Element_Radio('options');
$pass->setLabel('Bloquear:')
->setRequired(true)
->addMultiOptions(array(
'option1' => '<label for="options-1"></label><label>Option 1</label>',
'option2' => '<label for="options-2"></label><label>Option 2</label>'));
return $pass;但它会像打印非HTML一样打印标签。有什么建议吗?
发布于 2013-04-30 12:38:21
您必须定义自定义装饰器,如下例所示,以便使用<ul>和<li>进行管理
在ul和li的基础上应用css会很容易。看看这个
$this->addElement('radio', 'Bloquear', array(
'decorators' => array(
'ViewHelper',
array(array('AddTheLi' => 'HtmlTag'), array('tag' => 'li')),
array(array('AddTheUl' => 'HtmlTag'), array('tag' => 'ul')),
'Errors',
array('Description', array('tag' => 'p', 'class' => 'description')),
// specifying the "div" tag to wrap your <label> elements is not strictly
// necessary, but it produces valid XHTML if your form elements are wrapped
// in block-level tags like "<li>" (see next comment)
array('Label', array('tag' => 'div')),
// uncomment the following if all of your form elements are wrapped in "<li>"
//array('HtmlTag', array('tag' => 'li')),
),
'disableLoadDefaultDecorators' => true,
'label' => 'Bloquear',
'separator' => '</li><li>',
'attribs' => array(
'options' => array(
'foo' => 'Option 1',
'bar' => 'Option 2',
'baz' => 'Option 3'
),
),));
如果我能为你提供更多帮助,请告诉我。
https://stackoverflow.com/questions/16284046
复制相似问题