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
This commit is contained in:
parent
4351603243
commit
0111fdf78e
|
@ -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', ' <span aria-hidden="true">*</span>');
|
||||
}
|
||||
}
|
||||
|
||||
return $element;
|
||||
|
|
Loading…
Reference in New Issue