简体   繁体   中英

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

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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