diff options
author | Phil Davis <phil.davis@inf.org> | 2015-12-22 20:34:43 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2015-12-22 20:34:43 +0545 |
commit | 5736b2ce513ab3a9065f32f74a754ed4d815894a (patch) | |
tree | 0b1ed52564760171e74b8443ea454730688f2051 | |
parent | f84d2a908c5e40a17867a091ca5770ec03618178 (diff) | |
download | pfsense-5736b2ce513ab3a9065f32f74a754ed4d815894a.zip pfsense-5736b2ce513ab3a9065f32f74a754ed4d815894a.tar.gz |
HTML Compliance - Form Select 3rd try
This is a combined version of:
https://github.com/pfsense/pfsense/pull/2310
https://github.com/pfsense/pfsense/pull/2315
-rw-r--r-- | src/usr/local/www/classes/Form/Select.class.php | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/usr/local/www/classes/Form/Select.class.php b/src/usr/local/www/classes/Form/Select.class.php index c7d73c1..13c49f7 100644 --- a/src/usr/local/www/classes/Form/Select.class.php +++ b/src/usr/local/www/classes/Form/Select.class.php @@ -66,7 +66,14 @@ class Form_Select extends Form_Input $selected = ($sval == $value); } - $options .= '<option value="'. htmlspecialchars($value) .'"'.($selected ? ' selected' : '').'>'. htmlspecialchars(gettext($name)) .'</option>'; + if (!empty(trim($name)) || is_numeric($name)) { + $name_str = htmlspecialchars(gettext($name)); + } else { + // Fixes HTML5 validation: Element option without attribute label must not be empty + $name_str = " "; + } + + $options .= '<option value="'. htmlspecialchars($value) .'"'.($selected ? ' selected' : '').'>'. $name_str .'</option>'; } return <<<EOT @@ -75,4 +82,4 @@ class Form_Select extends Form_Input </select> EOT; } -}
\ No newline at end of file +} |