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