mirror of
https://github.com/vrana/adminer.git
synced 2025-08-09 16:17:48 +02:00
Accessibility: Use <option>(label) as label
This commit is contained in:
@@ -90,9 +90,17 @@ function optionlist($options, $selected = null, bool $use_keys = false): string
|
|||||||
* @param string[] $options
|
* @param string[] $options
|
||||||
*/
|
*/
|
||||||
function html_select(string $name, array $options, ?string $value = "", string $onchange = "", string $labelled_by = ""): string {
|
function html_select(string $name, array $options, ?string $value = "", string $onchange = "", string $labelled_by = ""): string {
|
||||||
|
static $label = 0;
|
||||||
|
$label_option = "";
|
||||||
|
if (!$labelled_by && substr($options[""], 0, 1) == "(") {
|
||||||
|
$label++;
|
||||||
|
$labelled_by = "label-$label";
|
||||||
|
$label_option = "<option value='' id='$labelled_by'>" . h($options[""]);
|
||||||
|
unset($options[""]);
|
||||||
|
}
|
||||||
return "<select name='" . h($name) . "'"
|
return "<select name='" . h($name) . "'"
|
||||||
. ($labelled_by ? " aria-labelledby='$labelled_by'" : "")
|
. ($labelled_by ? " aria-labelledby='$labelled_by'" : "")
|
||||||
. ">" . optionlist($options, $value) . "</select>"
|
. ">" . $label_option . optionlist($options, $value) . "</select>"
|
||||||
. ($onchange ? script("qsl('select').onchange = function () { $onchange };", "") : "")
|
. ($onchange ? script("qsl('select').onchange = function () { $onchange };", "") : "")
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user