<?php

use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\Tree;

/**
 * @var Family|null $family
 * @var string|null $class
 * @var string|null $id
 * @var string      $name
 * @var Tree        $tree
 */

?>

<select
    autocomplete="off"
    class="form-control select2 <?= $class ?? '' ?>"
    data-ajax--delay="350"
    data-minimum-input-length="2"
    data-ajax--type="POST"
    data-ajax--url="<?= e(route('select2-family', ['tree' => $tree->name()])) ?>"
    data-allow-clear="true"
    data-placeholder=""
    id="<?= e($id ?? $name) ?>"
    name="<?= e($name) ?>"
    <?= ($disabled ?? false) ? 'disabled' : '' ?>
    <?= ($required ?? false) ? 'required' : '' ?>
>
    <?php if (($family ?? null) instanceof Family): ?>
        <option value="<?= e($family->xref()) ?>">
            <?= view('selects/family', ['family' => $family]) ?>
        </option>
    <?php else: ?>
        <option></option>
    <?php endif ?>
</select>
