如何更改标签zend框架1.12的样式


how to change the styling of label zend framework 1.12

嗨,我正在使用zend,我想在特定标签中添加一些样式,我该如何

class Application_Form_CategoryEnablingItemsForm extends Zend_Form {
     public $elementDecorators = array(
        'ViewHelper',
        'Errors',
        array('Description', array('tag' => 'p', 'class' => 'description')),
        array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'col-md-4 displaycls')),
        array('Label', array('class' => 'col-md-3 control-label displaylbl', 'requiredSuffix' => '*')),
        array('Errors', array('class' => 'zend-error'))
    );
$this->addElement('select', 'product_category_parent', array(
            'label' => 'Product Category Parent Name',
            'required' => true,
            'multiOptions' => $productCategory_options,
            'filters' => array('StringTrim'),
            'class' => 'form-control selection parent_category',
        ));
        $productCategory_sub = $productCategoryMapper->getAllProductCategory();
        $productCategory_sub_options = array();
        $productCategory_sub_options[""]= "-Product Sub Category Name-";
        if($productCategory_sub)
        {
            foreach ($productCategory_sub as $category)
            {
                $productCategory_sub_options[$category->product_category_id] = $category->product_category_name;
            }
        }

我添加了'attribs' => array ('style' => 'margin-left: -799px; ')

但它适用于整体选择选项,不适用于标签,有什么建议吗?

试试下面的代码,只需添加您的标签样式类来代替我的类名类。

       $element = $this->createElement("select", 'product_category_parent');
        $element->setLabel('Product Category Parent Name');
        $element->setRequired(TRUE);
        $element->addMultiOptions($productCategory_options);
        $element->setAttrib("class", 'form-control selection parent_category');
        $element->removeDecorator('HtmlTag');
        $element->setDecorators(array('ViewHelper'));
        $element->getDecorator('Label')->setOption('class', 'my-class-name');