Ensure that all required form elements are marked as such in HTML markup
refs #8349
This commit is contained in:
parent
707d977cfc
commit
c5b6d7ee41
|
@ -6,6 +6,7 @@ namespace Icinga\Web;
|
||||||
use LogicException;
|
use LogicException;
|
||||||
use Zend_Config;
|
use Zend_Config;
|
||||||
use Zend_Form;
|
use Zend_Form;
|
||||||
|
use Zend_Form_Element;
|
||||||
use Zend_View_Interface;
|
use Zend_View_Interface;
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Authentication\Manager;
|
use Icinga\Authentication\Manager;
|
||||||
|
@ -550,7 +551,24 @@ class Form extends Zend_Form
|
||||||
unset($el->autosubmit);
|
unset($el->autosubmit);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $el;
|
return $this->ensureElementAccessibility($el);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add accessibility related attributes
|
||||||
|
*
|
||||||
|
* @param Zend_Form_Element $element
|
||||||
|
*
|
||||||
|
* @return Zend_Form_Element
|
||||||
|
*/
|
||||||
|
public function ensureElementAccessibility(Zend_Form_Element $element)
|
||||||
|
{
|
||||||
|
if ($element->isRequired() && strpos(strtolower($element->getType()), 'checkbox') === false) {
|
||||||
|
$element->setAttrib('aria-required', 'true'); // ARIA
|
||||||
|
$element->setAttrib('required', ''); // HTML5
|
||||||
|
}
|
||||||
|
|
||||||
|
return $element;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue