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