diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index c7e613e7b..265da8420 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -157,7 +157,7 @@ class Form extends Zend_Form public static $defaultElementDecorators = array( array('ViewHelper', array('separator' => '')), array('Errors', array('separator' => '')), - array('Help'), + array('Help', array('placement' => 'PREPEND')), array('Label', array('separator' => '')), array('HtmlTag', array('tag' => 'div', 'class' => 'element')) ); diff --git a/library/Icinga/Web/Form/Decorator/Help.php b/library/Icinga/Web/Form/Decorator/Help.php index a02443994..152d548af 100644 --- a/library/Icinga/Web/Form/Decorator/Help.php +++ b/library/Icinga/Web/Form/Decorator/Help.php @@ -76,18 +76,35 @@ class Help extends Zend_Form_Decorator_Abstract */ public function render($content = '') { - if ($content && ($description = $this->getElement()->getDescription()) !== null) { + $element = $this->getElement(); + $description = $element->getDescription(); + $requirement = $element->getAttrib('requirement'); + unset($element->requirement); + + $helpContent = ''; + if ($description || $requirement) { if ($this->accessible) { - $content = 'getDescriptionId() . '" class="sr-only">' . $description - . '' . $content; + . ($description && $requirement ? ' ' : '') + . $requirement + . ''; } - $content = $this->getView()->icon('help', $description, array('aria-hidden' => 'true')) . $content; + $helpContent = $this->getView()->icon( + 'help', + $description . ($description && $requirement ? ' ' : '') . $requirement, + array('aria-hidden' => $this->accessible ? 'true' : 'false') + ) . $helpContent; } - return $content; + switch ($this->getPlacement()) { + case self::APPEND: + return $content . $helpContent; + case self::PREPEND: + return $helpContent . $content; + } } }