【问题标题】:Zend Form Decorators to embed label and elementsZend Form Decorators 嵌入标签和元素
【发布时间】:2013-01-23 18:26:57
【问题描述】:

我完全不知道如何在 Zend 中使用装饰器!

如果您创建一个没有装饰器的基本简单表单,则标签进入 DT,元素进入 DD。而且都是一个接一个。

那么我该如何让每个标签及其对应的元素也进入一个 div 呢?

非常感谢! 口沙

【问题讨论】:

    标签: css zend-framework decorator


    【解决方案1】:

    我喜欢装饰师!但是它们非常难以掌握。幸好你的问题很简单。

    我在表单中使用了这个函数

    public function getElementDecorators()
    {
        return array(
            'ViewHelper',
            'Errors',
            array('Description', array('tag' => 'p', 'class' => 'description')),
            array('HtmlTag', array('tag' => 'dd', 'id'  => array('callback' => array(get_class($this), 'resolveElementId')))),
            array('Label', array('tag' => 'dt')),
            array(array('elementContainer' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-container')),
        );
    }
    

    然后对于表单中的每个元素,我都会像这样创建它们。

    $this->addElement('Text', 'wordup', array(
        'label' => 'Put your words here',
        'attribs' => array('class' => 'textbox-fancy'),
        'decorators' => $this->getElementDecorators()
    ));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-03
      • 2011-04-17
      • 1970-01-01
      • 2015-07-28
      • 2011-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多