xref: /webtrees/resources/views/components/select.phtml (revision 853f2b8ab920254b02a6cbbe9d6bf1f5c4486e2f)
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