xref: /webtrees/resources/views/components/select.phtml (revision a8b39ba2d349525974d59077419f7a8ea8802aaa)
1<?php
2
3/**
4 * @var string|null $class
5 * @var string|null $id
6 * @var string      $name
7 * @var mixed       $selected
8 * @var 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