diff --git a/lib/FormBuilder.lib.php b/lib/FormBuilder.lib.php index fa12936..13567cc 100644 --- a/lib/FormBuilder.lib.php +++ b/lib/FormBuilder.lib.php @@ -178,7 +178,10 @@ HTMLTOP; } $itemhtml = ""; $itemlabel = ""; - if ($item['type'] != "checkbox") { + + if ($item['type'] == "textarea") { + $itemlabel = ""; + } else if ($item['type'] != "checkbox") { $itemlabel = ""; } $strippedlabel = strip_tags($item['label']); @@ -186,13 +189,16 @@ HTMLTOP; \n\n
$itemlabel -
+ITEMTOP; + $inputgrouptop = <<
-ITEMTOP; +INPUTG; switch ($item['type']) { case "select": + $itemhtml .= $inputgrouptop; $itemhtml .= <<"; break; case "checkbox": + $itemhtml .= $inputgrouptop; $itemhtml .= << @@ -213,7 +220,14 @@ SELECT;
CHECKBOX; break; + case "textarea": + $val = htmlentities($item['value']); + $itemhtml .= << +TEXTAREA; + break; default: + $itemhtml .= $inputgrouptop; $itemhtml .= << INPUT; @@ -227,9 +241,11 @@ INPUT;
ERROR; } + if ($item["type"] != "textarea") { + $itemhtml .= "\n
"; + } $itemhtml .= << - +\n \n ITEMBOTTOM; $html .= $itemhtml; diff --git a/pages/form.php b/pages/form.php index 3a9cc52..d047a5f 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("textbox", "Hello world", "textarea", true, null, null, "Text area", "fas fa-font"); $form->addInput("box", "1", "checkbox", true, null, null, "I agree to the terms of service"); $form->addButton("Submit", "fas fa-save", null, "submit", "savebtn");