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