xref: /webtrees/resources/views/components/select.phtml (revision 2ebcf907ed34213f816592af04e6c160335d6311)
1<?php
2
3/**
4 * @var string|null   $class
5 * @var string|null   $id
6 * @var string        $name
7 * @var mixed         $selected
8 * @var array<string> $options
9 * @var string|null   $aria_label
10 */
11
12?>
13
14<select
15    class="form-select <?= $class ?? '' ?>"
16    name="<?= e($name) ?>"
17    id="<?= e($id ?? $name) ?>"
18    <?= is_array($selected) ? 'multiple="multiple"' : '' ?>
19    aria-label="<?= e($aria_label ?? '') ?>"
20
21>
22    <?php foreach ($options as $key => $value) : ?>
23        <option value="<?= e((string) $key) ?>"<?= (is_array($selected) ? in_array($key, $selected, false) : (string) $key === (string) $selected) ?  ' selected="selected"' : '' ?>>
24            <?= $value === '' ? '&nbsp;' : e($value) ?>
25        </option>
26    <?php endforeach ?>
27</select>
28