I am trying to set display:none attribute to Zend_Element_Checkbox. I have managed to hide checkbox itself. Unfortunately label keeps on displaying still.
Here is my code:
$this->addElement('Select', 'junior_accounts', array(
'label' => 'Junior (15yrs & under)',
'multiOptions' => $personNumberList,
'tabindex' => $tabIndex++,
));
$this->getElement('junior_accounts')->setAttribs(array('style' => 'display: none'));
Is there any programmatical method of doing this or I need to set class of the element and add appropriate CSS definition?
Thanks!
You can get access to the label of the Zend_Form_Element
via Zend_Form_Element::getDecorator()
. Then you can set the style
option of the decorator to control its CSS properties.
$label = $this->getElement('junior_accounts')->getDecorator('Label');
if ($label instanceof Zend_Form_Decorator_Abstract) {
$label->setOption('style', 'display: none');
}