xref: /webtrees/resources/views/components/select.phtml (revision 3d9e70a53ebdea3db408ada1769711840cc7d14c)
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-control <?= $class ?? '' ?>"
16    name="<?= e($name) ?>"
17    id="<?= e($id ?? $name) ?>"
18    <?= is_array($selected) ? '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