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