【问题标题】:How to add a custom class to all the elements of a Zend Form?如何为 Zend 表单的所有元素添加自定义类?
【发布时间】:2013-10-06 08:27:36
【问题描述】:

其实我有:

$this->setElementDecorators(array(
        'ViewHelper',
        'Label',
        'HtmlTag', array('HtmlTag', array('tag' => 'div', 'class' => 'form-group'))
));

我已经用<div class="form-group"></div> 包裹了我的元素。 我想这与ViewHelper有关,但我不知道是什么。有什么帮助吗?

【问题讨论】:

    标签: php zend-framework twitter-bootstrap zend-form decorator


    【解决方案1】:

    您是否尝试使用 Zend_Form 类为每个生成的表单元素添加一个类?我的做法是这样的:

        $firstname = new Zend_Form_Element_Text('first_name');
        $firstname->setLabel('First Name:')
            ->setAttribs(array('id' => 'first_name', 'class' => 'input-text-field'))
            ->setRequired(true)
            ->addValidator('StringLength', false, array(1, 30))
            ->addFilters(array('StringTrim'))
            ->addErrorMessage('Please enter first Name');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-07
      • 2014-07-18
      • 1970-01-01
      • 2013-02-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多