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