should be created to describe the decorated form element * * @var bool */ protected $accessible = false; /** * The id used to identify the description associated with the decorated form element * * @var string */ protected $descriptionId; /** * Set whether a hidden should be created to describe the decorated form element * * @param bool $state * * @return Help */ public function setAccessible($state = true) { $this->accessible = (bool) $state; return $this; } /** * Return the id used to identify the description associated with the decorated element * * @param Zend_Form_Element $element The element for which to generate a id * * @return string */ public function getDescriptionId(Zend_Form_Element $element = null) { if ($this->descriptionId === null) { $element = $element ?: $this->getElement(); $this->descriptionId = 'desc_' . $element->getId(); } return $this->descriptionId; } /** * Return the current view * * @return View */ protected function getView() { return Icinga::app()->getViewRenderer()->view; } /** * Add a help icon to the left of an element * * @param string $content The html rendered so far * * @return ?string The updated html */ public function render($content = '') { $element = $this->getElement(); $description = $element->getDescription(); $requirement = $element->getAttrib('requirement'); unset($element->requirement); $helpContent = ''; if ($description || $requirement) { if ($this->accessible) { $helpContent = '' . $description . ($description && $requirement ? ' ' : '') . $requirement . ''; } $helpContent = $this->getView()->icon( 'info-circled', $description . ($description && $requirement ? ' ' : '') . $requirement, array( 'class' => 'control-info', 'aria-hidden' => $this->accessible ? 'true' : 'false' ) ) . $helpContent; } switch ($this->getPlacement()) { case self::APPEND: return $content . $helpContent; case self::PREPEND: return $helpContent . $content; } } }