xref: /webtrees/resources/views/components/select.phtml (revision add3fa4120ca696c713a0d0ac9b9c86f751fe49a)
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) || $key == $selected ?  'selected' : '' ?>>
21            <?= e($value) ?>
22        </option>
23    <?php endforeach ?>
24</select>
25