blob: 6d5be54f594e10a26a83cc9818154c2d44fd3f0b (
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) || !is_array($selected) && (string) $key === (string) $selected ? 'selected' : '' ?>>
<?= e($value) ?>
</option>
<?php endforeach ?>
</select>
|