【问题标题】:Zend Framework: how to order decorators correct?Zend Framework:如何正确订购装饰器?
【发布时间】:2011-06-27 03:39:01
【问题描述】:

我想做一个这样的:

<div><input type="checkbox" /> <label>Check this</label></div>

但不是这样的:

<div><label>Check this</label><input type="checkbox" /></div>

我尝试过这样做:

$stayInSystem->addDecorators(array(
                  'ViewHelper',
                  array('Label'),
                  array(array('row' => 'HtmlTag'), array('tag' => 'div',)),
      ))->setLabel('Check this');

提前致谢

【问题讨论】:

  • 当你尝试这样做时发生了什么?
  • 并尝试将addDecorators 替换为setDecorators
  • 所以,我解决了这个问题。刚刚添加:array('Label', array('placement' => 'append')).

标签: html zend-framework label decorator


【解决方案1】:

标签的装饰器顺序由 Zend_Form_Decorator_Label 中的 "$_placement" 设置。 您可以创建此类的派生并设置:

protected $_placement = 'APPEND';

另外,可以在 addDecorator 中传递“array('placement'=>'APPEND')”,像这样:

$stayInSystem->addDecorators(array(
              'ViewHelper',
              array('Label', array('placement'=>'APPEND')),
              array(array('row' => 'HtmlTag'), array('tag' => 'div',)),
))->setLabel('Check this');

希望对你有帮助...

阿卡。

【讨论】:

    猜你喜欢
    • 2011-01-20
    • 1970-01-01
    • 2012-10-23
    • 1970-01-01
    • 2011-12-29
    • 1970-01-01
    • 2012-10-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多