xref: /webtrees/resources/views/components/select.phtml (revision f7cf8a155e2743f3d124eef3d30a558ab062fa4b)
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 */
10
11?>
12
13<select
14    class="form-control <?= $class ?? '' ?>"
15    name="<?= e($name) ?>"
16    id="<?= e($id ?? $name) ?>"
17    <?= is_array($selected) ? 'multiple' : '' ?>
18>
19    <?php foreach ($options as $key => $value) : ?>
20        <option value="<?= e((string) $key) ?>"<?= (is_array($selected) ? in_array($key, $selected, false) : (string) $key === (string) $selected) ?  ' selected="selected"' : '' ?>>
21            <?= $value === '' ? '&nbsp;' : e($value) ?>
22        </option>
23    <?php endforeach ?>
24</select>
25