简体   繁体   English

如何更改标签zend Framework 1.12的样式

[英]how to change the styling of label zend framework 1.12

Hi i am using zend i want to put some styling in specific label how can i 嗨,我正在使用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;
            }
        }

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

but its working for whole select options not working for label,Any suggestions? 但是它对整个选择选项都起作用,对标签不起作用,有什么建议吗?

Try below code and just add your lable style class in place of my-class-name class. 尝试下面的代码,仅添加标签样式类代替my-class-name类。

       $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');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM