xref: /webtrees/resources/views/edit/add-fact-row.phtml (revision c3e5dff841892e112f556db14f7a8664306322c2)
1<?php
2
3use Fisharebest\Webtrees\Family;
4use Fisharebest\Webtrees\GedcomTag;
5use Fisharebest\Webtrees\Http\RequestHandlers\AddNewFact;
6use Fisharebest\Webtrees\Http\RequestHandlers\SelectNewFact;
7use Fisharebest\Webtrees\I18N;
8use Fisharebest\Webtrees\Individual;
9
10?>
11
12<tr>
13    <th scope="row">
14        <label for="add-fact">
15            <?= I18N::translate('Fact or event') ?>
16        </label>
17    </th>
18    <td>
19        <form method="post" action="<?= e(route(SelectNewFact::class, ['tree' => $record->tree()->name(), 'xref' => $record->xref()])) ?>" onsubmit="if ($('#add-fact').val() === null) {event.preventDefault();}">
20            <?= csrf_field() ?>
21
22            <div class="input-group">
23                <select class="custom-select" id="add-fact" name="fact">
24                    <option value="" disabled selected>
25                        <?= I18N::translate('&lt;select&gt;') ?>
26                    </option>
27                    <?php foreach ($add_facts as $fact => $fact_name) : ?>
28                        <option value="<?= $fact ?>"><?= $fact_name ?></option>
29                    <?php endforeach ?>
30                    <?php if ($record::RECORD_TYPE === Individual::RECORD_TYPE || $record::RECORD_TYPE === Family::RECORD_TYPE) : ?>
31                        <option value="FACT">
32                        <?= I18N::translate('Custom fact') ?>
33                        </option>
34                    <option value="EVEN">
35                        <?= I18N::translate('Custom event') ?>
36                    </option>
37                    <?php endif ?>
38                </select>
39                <div class="input-group-append">
40                    <button class="btn btn-light" type="submit">
41                        <?= /* I18N: A button label. */ I18N::translate('add') ?>
42                    </button>
43                </div>
44            </div>
45        </form>
46
47        <div class="wt-quick-facts">
48            <?php foreach ($quick_facts as $fact) : ?>
49                <a class="btn btn-link btn-sm wt-quick-fact" href="<?= e(route(AddNewFact::class, [
50                    'fact' => $fact,
51                    'xref' => $record->xref(),
52                    'tree' => $tree->name(),
53                ])) ?>">
54                    <?= GedcomTag::getLabel($fact) ?>
55                </a>
56            <?php endforeach ?>
57        </div>
58    </td>
59</tr>
60