xref: /webtrees/resources/views/components/select-media.phtml (revision b6c326d8b8798b83b744c4d4a669df5aa9f3e0c2)
1<?php
2
3use Fisharebest\Webtrees\Media;
4use Fisharebest\Webtrees\Tree;
5
6/**
7 * @var Media|null $media
8 * @var string|null $id
9 * @var string      $name
10 * @var Tree        $tree
11 */
12
13?>
14
15<select
16    autocomplete="off"
17    class="form-control select2"
18    data-ajax--delay="350"
19    data-ajax--minimum-input-length="2"
20    data-ajax--type="POST"
21    data-ajax--url="<?= e(route('select2-media', ['ged' => $tree->name()])) ?>"
22    data-allow-clear="true"
23    id="<?= e($id ?? $name) ?>"
24    name="<?= e($name) ?>"
25    <?= ($disabled ?? false) ? 'disabled' : '' ?>
26    <?= ($required ?? false) ? 'required' : '' ?>
27>
28    <?php if (($media ?? null) instanceof Media): ?>
29        <option value="<?= e($media->xref()) ?>" selected>
30            <?= view('selects/media', ['media' => $media]) ?>
31        </option>
32    <?php else: ?>
33        <option></option>
34    <?php endif ?>
35</select>
36