【问题标题】:Set a Zend Decoration for radio element为单选元素设置 Zend 装饰
【发布时间】:2013-04-29 16:50:56
【问题描述】:

我需要为打印设置一个装饰:

<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 一样打印标签。有什么建议吗?

【问题讨论】:

  • “打印”是什么意思?为什么要一个空标签标签?
  • 表示显示、显示... 用于使用 CSS 自定义单选按钮。 ^^

标签: zend-framework zend-form zend-form-element zend-decorators


【解决方案1】:

您必须按照以下示例定义自定义装饰器才能使用&lt;ul&gt;&lt;li&gt; 进行管理

在 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'
    ),
),

));

如果我可以为您提供更多帮助,请告诉我。

【讨论】:

  • 对不起@liyakat,这不能回答我的问题。
  • 它显示类似: 换句话说,输入在标签内。已经测试了几十种类似的东西。
猜你喜欢
  • 1970-01-01
  • 2013-07-25
  • 2012-03-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-26
  • 1970-01-01
相关资源
最近更新 更多