xref: /webtrees/resources/views/edit/add-fact-row.phtml (revision f75be1338c0f1f48e2889f2c0c1e1513ad7ed76b)
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                    <div class="input-group-append">
41                        <button class="btn btn-light" type="submit">
42                            <?= /* I18N: A button label. */ I18N::translate('add') ?>
43                        </button>
44                    </div>
45                </div>
46            </form>
47        <?php endif ?>
48
49        <div class="wt-quick-facts">
50            <?php foreach ($quick_facts as $fact => $label) : ?>
51                <a class="btn btn-link wt-quick-fact" href="<?= e(route(AddNewFact::class, [
52                    'fact' => $fact,
53                    'xref' => $record->xref(),
54                    'tree' => $record->tree()->name(),
55                ])) ?>">
56                    <?= $label ?>
57                </a>
58            <?php endforeach ?>
59        </div>
60    </td>
61</tr>
62