diff --git a/library/Zend/Form/Decorator/Label.php b/library/Zend/Form/Decorator/Label.php old mode 100644 new mode 100755 index 4d17c4f..45ab8ba --- a/library/Zend/Form/Decorator/Label.php +++ b/library/Zend/Form/Decorator/Label.php @@ -57,6 +57,13 @@ class Zend_Form_Decorator_Label extends Zend_Form_Decorator_Abstract */ protected $_tag; + + /** + * Options for HTML tag with which to surround label + * @var array + */ + protected $_tagOptions; + /** * Set element ID * @@ -125,6 +132,44 @@ class Zend_Form_Decorator_Label extends Zend_Form_Decorator_Abstract return $this->_tag; } + + /** + * Set options for HTML tag with which to surround label + * + * @param array $tagOptions + * @return Zend_Form_Decorator_Label + */ + public function setTagOptions($tagOptions) + { + if (empty($tagOptions)) { + $this->_tagOptions = null; + } else { + $this->_tagOptions = (array) $tagOptions; + } + return $this; + } + + /** + * Get options for HTML tag, if any, with which to surround label + * + * @return void + */ + public function getTagOptions() + { + if (null === $this->_tagOptions) { + $tagOptions = $this->getOption('tagOptions'); + if (null !== $tagOptions) { + $this->removeOption('tagOptions'); + $this->setTagOptions($tagOptions); + } + return $tagOptions; + } + + return $this->_tagOptions; + } + + + /** * Get class with which to define label * @@ -294,6 +339,7 @@ class Zend_Form_Decorator_Label extends Zend_Form_Decorator_Abstract $separator = $this->getSeparator(); $placement = $this->getPlacement(); $tag = $this->getTag(); + $tagOptions = $this->getTagOptions(); $id = $this->getId(); $class = $this->getClass(); $options = $this->getOptions(); @@ -313,8 +359,12 @@ class Zend_Form_Decorator_Label extends Zend_Form_Decorator_Abstract if (null !== $tag) { require_once 'Zend/Form/Decorator/HtmlTag.php'; $decorator = new Zend_Form_Decorator_HtmlTag(); - $decorator->setOptions(array('tag' => $tag, - 'id' => $this->getElement()->getName() . '-label')); + + $decoratorOptions = array('tag' => $tag, 'id' => $this->getElement()->getName() . '-label'); + if(!empty($tagOptions)) { + $decoratorOptions = array_merge((array) $tagOptions,$decoratorOptions); + } + $decorator->setOptions($decoratorOptions); $label = $decorator->render($label); }