diff --git a/lib/FormBuilder.lib.php b/lib/FormBuilder.lib.php index fddbff2..a07919b 100644 --- a/lib/FormBuilder.lib.php +++ b/lib/FormBuilder.lib.php @@ -173,33 +173,50 @@ HTMLTOP; $required = $item["required"] ? "required" : ""; $id = empty($item["id"]) ? "" : "id=\"$item[id]\""; $pattern = empty($item["pattern"]) ? "" : "pattern=\"$item[pattern]\""; - + if (empty($item['type'])) { + $item['type'] = "text"; + } $itemhtml = ""; + $itemlabel = ""; + if ($item['type'] != "checkbox") { + $itemlabel = ""; + } $itemhtml .= <<
- + $itemlabel
ITEMTOP; - if (empty($item['type']) || $item['type'] != "select") { - $itemhtml .= << -INPUT; - } else { - $itemhtml .= <<"; + $itemhtml .= "\n "; + break; + case "checkbox": + $itemhtml .= << + + +
+CHECKBOX; + break; + default: + $itemhtml .= << +INPUT; + break; } if (!empty($item["error"])) { diff --git a/pages/form.php b/pages/form.php index 7cd7fdd..3a9cc52 100644 --- a/pages/form.php +++ b/pages/form.php @@ -18,6 +18,7 @@ $form->addHiddenInput("page", "form"); $form->addInput("name", "John", "text", true, null, null, "Your name", "fas fa-user", 6, 5, 20, "John(ny)?|Steve", "Invalid name, please enter John, Johnny, or Steve."); $form->addInput("location", "", "select", true, null, ["1" => "Here", "2" => "There"], "Location", "fas fa-map-marker"); +$form->addInput("box", "1", "checkbox", true, null, null, "I agree to the terms of service"); $form->addButton("Submit", "fas fa-save", null, "submit", "savebtn");