xref: /webtrees/resources/views/edit/change-family-members.phtml (revision ac71572d8462e396ed5a307f05b29381e49f9e6e)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Family;
6use Fisharebest\Webtrees\Http\RequestHandlers\ChangeFamilyMembersAction;
7use Fisharebest\Webtrees\I18N;
8use Fisharebest\Webtrees\Individual;
9use Fisharebest\Webtrees\Tree;
10use Illuminate\Support\Collection;
11
12/**
13 * @var Collection<int,Individual> $children
14 * @var Family                     $family
15 * @var Individual|null            $father
16 * @var Individual|null            $mother
17 * @var string                     $title
18 * @var Tree                       $tree
19 */
20
21?>
22
23<h2 class="wt-page-title"><?= $title ?></h2>
24
25<form method="post" action="<?= e(route(ChangeFamilyMembersAction::class, ['tree' => $tree->name()])) ?>" class="wt-page-content" name="changefamform">
26    <input type="hidden" name="tree" value="<?= e($tree->name()) ?>">
27    <input type="hidden" name="xref" value="<?= e($family->xref()) ?>">
28
29    <div class="row">
30        <label class="col-sm-3 col-form-label wt-page-options-label" for="HUSB">
31            <?php if ($father instanceof Individual && $father->sex() === 'M') : ?>
32                <?= I18N::translate('Husband') ?>
33            <?php elseif ($father !== null && $father->sex() === 'F') : ?>
34                <?= I18N::translate('Wife') ?>
35            <?php else : ?>
36                <?= I18N::translate('Spouse') ?>
37            <?php endif ?>
38        </label>
39        <div class="col-sm-9 wt-page-options-value">
40            <?= view('components/select-individual', ['name' => 'HUSB', 'individual' => $father, 'tree' => $tree]) ?>
41        </div>
42    </div>
43
44    <div class="row">
45        <label class="col-sm-3 col-form-label wt-page-options-label" for="WIFE">
46            <?php if ($mother  instanceof Individual && $mother->sex() === 'M') : ?>
47                <?= I18N::translate('Husband') ?>
48            <?php elseif ($mother !== null && $mother->sex() === 'F') : ?>
49                <?= I18N::translate('Wife') ?>
50            <?php else : ?>
51                <?= I18N::translate('Spouse') ?>
52            <?php endif ?>
53        </label>
54        <div class="col-sm-9 wt-page-options-value">
55            <?= view('components/select-individual', ['name' => 'WIFE', 'individual' => $mother, 'tree' => $tree]) ?>
56        </div>
57    </div>
58
59    <?php foreach ($children as $n => $child) : ?>
60        <div class="row">
61            <label class="col-sm-3 col-form-label wt-page-options-label" for="CHIL<?= e($n) ?>">
62                <?php if ($child !== null && $child->sex() === 'M') : ?>
63                    <?= I18N::translate('Son') ?>
64                <?php elseif ($child !== null && $child->sex() === 'F') : ?>
65                    <?= I18N::translate('Daughter') ?>
66                <?php else : ?>
67                    <?= I18N::translate('Child') ?>
68                <?php endif ?>
69            </label>
70            <div class="col-sm-9 wt-page-options-value">
71                <?= view('components/select-individual', ['name' => 'CHIL[]', 'id' => 'CHIL' . $n, 'individual' => $child, 'tree' => $tree]) ?>
72            </div>
73        </div>
74    <?php endforeach ?>
75
76    <div class="row">
77        <label class="col-sm-3 col-form-label wt-page-options-label" for="CHIL<?= e(count($children) + 1) ?>">
78            <?= I18N::translate('Child') ?>
79        </label>
80        <div class="col-sm-9 wt-page-options-value">
81            <?= view('components/select-individual', ['name' => 'CHIL[]', 'id' => 'CHIL' . (count($children) + 1), 'tree' => $tree]) ?>
82        </div>
83    </div>
84
85    <div class="row mb-3">
86        <div class="col-sm-3 wt-page-options-label">
87        </div>
88        <div class="col-sm-9 wt-page-options-value">
89            <button class="btn btn-primary" type="submit">
90                <?= view('icons/save') ?>
91                <?= /* I18N: A button label. */
92                I18N::translate('save') ?>
93            </button>
94            <a class="btn btn-secondary" href="<?= e($family->url()) ?>">
95                <?= view('icons/cancel') ?>
96                <?= /* I18N: A button label. */
97                I18N::translate('cancel') ?>
98            </a>
99        </div>
100    </div>
101
102    <?= csrf_field() ?>
103</form>
104