【问题标题】:zend_form decorator contentzend_form 装饰器内容
【发布时间】:2012-04-20 16:45:18
【问题描述】:

大家好,我在添加的 html 标记中添加文本时遇到问题

我有这个:

public $elementDecorators = array(
    'ViewHelper',
    'Errors',
    array('HtmlTag', array('tag' => 'span', 'class' => 'checkbox','description' => 'Club')),

public function init() {
    $this->setMethod('post');
    //$this->setAttrib('action','index');
    $this->addElement('checkbox', 'Club', array(
        'decorators' => $this->elementDecorators,
    ));
//omitted code

哪个输出:

<span class="checkbox" markup="Club" description="Club">
<input type="hidden" name="Club" value="0"><input type="checkbox" name="Club" id="Club"  value="1"></span>

而我需要做的是拥有这个:

<span class="checkbox" markup="Club" description="Club">This is club
<input type="hidden" name="Club" value="0"><input type="checkbox" name="Club" id="Club"  value="1"></span>

我认为这不应该那么难,但我想不出一个简单/好的方法来做到这一点。 有什么要求吗?

【问题讨论】:

    标签: html forms zend-framework decorator


    【解决方案1】:

    很遗憾,您无法向 HtmlTag 装饰器添加内容。你需要自己写,或者使用回调装饰器 - 检查这个答案https://stackoverflow.com/a/9812186/1278879

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多