summaryrefslogtreecommitdiff
path: root/resources/views/components/select.phtml
blob: 209ba449263fe334f607904db80ffc8d0a37aed7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php

/**
 * @var string|null $class
 * @var string|null $id
 * @var string      $name
 * @var mixed       $selected
 * @var string[]    $options
 */

?>

<select
    class="form-control <?= $class ?? '' ?>"
    name="<?= e($name) ?>"
    id="<?= e($id ?? $name) ?>"
    <?= is_array($selected) ? 'multiple' : '' ?>
>
    <?php foreach ($options as $key => $value) : ?>
        <option value="<?= e((string) $key) ?>" <?= is_array($selected) && in_array($key, $selected, false) || (string) $key === (string) $selected ?  'selected' : '' ?>>
            <?= e($value) ?>
        </option>
    <?php endforeach ?>
</select>