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