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