I am working on one project in zend framework 1.12. for generating decorators I have created one class 'Application_Form_Base' which extends 'Zend_Form'. I have written code in this class in such a manned when I add new element with label decorator in my form it applies one css class 'field_label' on that label. The problem comes that for some form, I just want to remove this css class of the label at run time. anyone has idea, how can I remove this css class at run time when rending form elements?
Following is my intermediate form class
<?php
class Application_Form_Base extends Zend_Form
{
public $elementDecorators = array(
'ViewHelper',
'Errors',
array(
'label',
array(
'class' => 'field_label'
)
),
array(
array(
'row' => 'HtmlTag'
),
array(
'tag' => 'div',
'class' => 'form-row'
)
)
);
public $buttonDecorators = array(
'ViewHelper',
array(
array(
'label' => 'HtmlTag'
),
array(
'tag' => 'label',
'placement' => 'prepend',
'class'=>'field_label'
)
),
array(
array(
'row' => 'HtmlTag'
),
array(
'tag' => 'div',
'class' => 'form-row'
)
)
);
public function loadDefaultDecorators ()
{
$this->setDecorators(
array(
'FormElements',
array(
'HtmlTag',
array(
'tag' => 'div',
'class' => 'zendForm'
)
),
'Form'
));
}
}
following is snippet of my search form
class Admin_Form_SubscribeSearch extends Application_Form_Base
{
public function init()
{
$locale = Zend_Registry::get('Zend_Translate');
/* Form Elements & Other Definitions Here ... */
$this->setMethod('post');
$this->setName('searchPackage');
$this->addElement('text','name',array(
'label'=>$locale->translate('label_name'),
'required'=>true,
'decorators'=> $this->elementDecorators,
'filters'=>array('StringTrim'),
'class'=>'',
));
following is the html output generated for that form field.
<label class="field_label required" for="price">name</label>
I want to remove this 'field_label' class when rending form elements in the view. how can I achieve this?