xref: /webtrees/resources/views/components/select-media.phtml (revision 6765725587bce7e3b379fc9bfba89b92bda971f2)
1b6c326d8SGreg Roach<?php
2b6c326d8SGreg Roach
3203b6ccfSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\Select2MediaObject;
4b6c326d8SGreg Roachuse Fisharebest\Webtrees\Media;
5b6c326d8SGreg Roachuse Fisharebest\Webtrees\Tree;
6b6c326d8SGreg Roach
7b6c326d8SGreg Roach/**
8*67657255SGreg Roach * @var string      $at     "@" or "" (or unset).
9b6c326d8SGreg Roach * @var Media|null  $media
106bdf2178SGreg Roach * @var string|null $class
11b6c326d8SGreg Roach * @var string|null $id
12b6c326d8SGreg Roach * @var string      $name
13b6c326d8SGreg Roach * @var Tree        $tree
14b6c326d8SGreg Roach */
15b6c326d8SGreg Roach
16*67657255SGreg Roach$at = $at ?? '';
17*67657255SGreg Roach
18b6c326d8SGreg Roach?>
19b6c326d8SGreg Roach
20b6c326d8SGreg Roach<select
21b6c326d8SGreg Roach    autocomplete="off"
226bdf2178SGreg Roach    class="form-control select2 <?= $class ?? '' ?>"
23203b6ccfSGreg Roach    data-ajax--delay="<?= e(Select2MediaObject::AJAX_DELAY) ?>"
24203b6ccfSGreg Roach    data-minimum-input-length="<?= e(Select2MediaObject::MINIMUM_INPUT_LENGTH) ?>"
25b6c326d8SGreg Roach    data-ajax--type="POST"
26*67657255SGreg Roach    data-ajax--url="<?= e(route(Select2MediaObject::class, ['tree' => $tree->name(), 'at' => $at])) ?>"
27b6c326d8SGreg Roach    data-allow-clear="true"
280b4a90f1SGreg Roach    data-placeholder=""
29b6c326d8SGreg Roach    id="<?= e($id ?? $name) ?>"
30b6c326d8SGreg Roach    name="<?= e($name) ?>"
31b6c326d8SGreg Roach    <?= ($disabled ?? false) ? 'disabled' : '' ?>
32b6c326d8SGreg Roach    <?= ($required ?? false) ? 'required' : '' ?>
3364b4a654SGreg Roach    style="width:100%"
34b6c326d8SGreg Roach>
35b6c326d8SGreg Roach    <?php if (($media ?? null) instanceof Media) : ?>
36*67657255SGreg Roach        <option value="<?= e($at . $media->xref() . $at) ?>">
37b6c326d8SGreg Roach            <?= view('selects/media', ['media' => $media]) ?>
38b6c326d8SGreg Roach        </option>
39b6c326d8SGreg Roach    <?php else : ?>
40027478c2SGreg Roach        <option value="">&nbsp;</option>
41b6c326d8SGreg Roach    <?php endif ?>
42b6c326d8SGreg Roach</select>
43