Don't require both father and mother name

master
Skylar Ittner 1 year ago
parent 49f078c8fc
commit 83cfed0d0d

@ -60,17 +60,14 @@ switch ($VARS['action']) {
try { try {
$lastname = $VARS['familyname']; $lastname = $VARS['familyname'];
$father = $VARS['fathername']; $father = $VARS['fathername'] ?? "";
$mother = $VARS['mothername']; $mother = $VARS['mothername'] ?? "";
if (empty($lastname)) { if (empty($lastname)) {
errorBack("Enter a last name."); errorBack("Enter a last name.");
} }
if (empty($father)) { if (empty($father) && empty($mother)) {
errorBack("Enter a father name."); errorBack("Enter the father and/or mother's name.");
}
if (empty($mother)) {
errorBack("Enter a mother name.");
} }
$family->setName($lastname); $family->setName($lastname);

Binary file not shown.

@ -139,11 +139,11 @@ class Family {
} }
public function getFather(): string { public function getFather(): string {
return $this->father; return $this->father ?? "";
} }
public function getMother(): string { public function getMother(): string {
return $this->mother; return $this->mother ?? "";
} }
public function getPhone(): string { public function getPhone(): string {

@ -67,7 +67,8 @@ if (empty($VARS['id']) || !$database->has('families', ['familyid' => $VARS['id']
"name" => "fathername", "name" => "fathername",
"maxlength" => 255, "maxlength" => 255,
"value" => $family->getFather(), "value" => $family->getFather(),
"error" => "Enter the father's name." "error" => "Enter the father's name.",
"optional" => true
], ],
[ [
"label" => "Mother's Name", "label" => "Mother's Name",
@ -75,7 +76,8 @@ if (empty($VARS['id']) || !$database->has('families', ['familyid' => $VARS['id']
"name" => "mothername", "name" => "mothername",
"maxlength" => 255, "maxlength" => 255,
"value" => $family->getMother(), "value" => $family->getMother(),
"error" => "Enter the mother's name." "error" => "Enter the mother's name.",
"optional" => true
], ],
[ [
"label" => "Street Address", "label" => "Street Address",
@ -241,7 +243,9 @@ if (empty($VARS['id']) || !$database->has('families', ['familyid' => $VARS['id']
value="<?php echo htmlspecialchars($item['value']); ?>" value="<?php echo htmlspecialchars($item['value']); ?>"
<?php <?php
} }
?>required /> if (empty($item['optional'])) {
echo "required";
} ?>/>
<?php } else if ($item['type'] == "select") { ?> <?php } else if ($item['type'] == "select") { ?>
<select class="form-control" <select class="form-control"
name="<?php echo $item['name']; ?>" name="<?php echo $item['name']; ?>"

Loading…
Cancel
Save