Browse Source

Improve use of the FOR attribute in LABEL tags #1960

Angel Fernando Quiroz Campos 7 years ago
parent
commit
013347ff73
1 changed files with 6 additions and 0 deletions
  1. 6 0
      main/inc/lib/pear/HTML/QuickForm.php

+ 6 - 0
main/inc/lib/pear/HTML/QuickForm.php

@@ -585,6 +585,12 @@ class HTML_QuickForm extends HTML_Common
             $this->_elementIndex[$elementName] = end($elKeys);
         }
 
+        $elId = $elementObject->getAttribute('id');
+
+        if (empty($elId)) {
+            $elementObject->setAttribute('id', "{$this->getAttribute('name')}_$elementName");
+        }
+
         if ($this->_freezeAll) {
             $elementObject->freeze();
         }