From 0111fdf78ea9783d5ce2506001473c2ec7db6ad5 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 26 Feb 2015 16:05:13 +0100 Subject: [PATCH] Add an asterisk suffix to a form element's label if its required The screen reader part "(required)" is not being considered with this commit as most screen readers do not need this due to the ARIA and HTML5 property. resolves #7934 --- library/Icinga/Web/Form.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 014855849..fdc513c41 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -583,6 +583,11 @@ class Form extends Zend_Form if ($element->isRequired() && strpos(strtolower($element->getType()), 'checkbox') === false) { $element->setAttrib('aria-required', 'true'); // ARIA $element->setAttrib('required', ''); // HTML5 + if (($label = $element->getDecorator('label')) !== false) { + $element->setLabel($this->getView()->escape($element->getLabel())); + $label->setOption('escape', false); + $label->setOption('requiredSuffix', ' '); + } } return $element;