From c5b6d7ee41cb0edf272847a5d63d55e6c3452116 Mon Sep 17 00:00:00 2001
From: Johannes Meyer <johannes.meyer@netways.de>
Date: Thu, 5 Feb 2015 13:15:18 +0100
Subject: [PATCH] Ensure that all required form elements are marked as such in
 HTML markup

refs #8349
---
 library/Icinga/Web/Form.php | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php
index 1a75cb852..606a74f98 100644
--- a/library/Icinga/Web/Form.php
+++ b/library/Icinga/Web/Form.php
@@ -6,6 +6,7 @@ namespace Icinga\Web;
 use LogicException;
 use Zend_Config;
 use Zend_Form;
+use Zend_Form_Element;
 use Zend_View_Interface;
 use Icinga\Application\Icinga;
 use Icinga\Authentication\Manager;
@@ -550,7 +551,24 @@ class Form extends Zend_Form
             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;
     }
 
     /**