diff --git a/action.php b/action.php index 667e68d..28a9ad0 100644 --- a/action.php +++ b/action.php @@ -60,17 +60,14 @@ switch ($VARS['action']) { try { $lastname = $VARS['familyname']; - $father = $VARS['fathername']; - $mother = $VARS['mothername']; + $father = $VARS['fathername'] ?? ""; + $mother = $VARS['mothername'] ?? ""; if (empty($lastname)) { errorBack("Enter a last name."); } - if (empty($father)) { - errorBack("Enter a father name."); - } - if (empty($mother)) { - errorBack("Enter a mother name."); + if (empty($father) && empty($mother)) { + errorBack("Enter the father and/or mother's name."); } $family->setName($lastname); diff --git a/database.mwb b/database.mwb index c859bfc..5999809 100644 Binary files a/database.mwb and b/database.mwb differ diff --git a/lib/Family.lib.php b/lib/Family.lib.php index be35c46..1b39263 100644 --- a/lib/Family.lib.php +++ b/lib/Family.lib.php @@ -139,11 +139,11 @@ class Family { } public function getFather(): string { - return $this->father; + return $this->father ?? ""; } public function getMother(): string { - return $this->mother; + return $this->mother ?? ""; } public function getPhone(): string { diff --git a/pages/editfamily.php b/pages/editfamily.php index 97387a2..e1ca639 100644 --- a/pages/editfamily.php +++ b/pages/editfamily.php @@ -67,7 +67,8 @@ if (empty($VARS['id']) || !$database->has('families', ['familyid' => $VARS['id'] "name" => "fathername", "maxlength" => 255, "value" => $family->getFather(), - "error" => "Enter the father's name." + "error" => "Enter the father's name.", + "optional" => true ], [ "label" => "Mother's Name", @@ -75,7 +76,8 @@ if (empty($VARS['id']) || !$database->has('families', ['familyid' => $VARS['id'] "name" => "mothername", "maxlength" => 255, "value" => $family->getMother(), - "error" => "Enter the mother's name." + "error" => "Enter the mother's name.", + "optional" => true ], [ "label" => "Street Address", @@ -241,7 +243,9 @@ if (empty($VARS['id']) || !$database->has('families', ['familyid' => $VARS['id'] value="" required /> + if (empty($item['optional'])) { + echo "required"; + } ?>/>