// --------------------------------------------------------
include "forms.php";
print GenericForm();
// --------------------------------------------------------
// Function: GenericForm
// Description: Shows how to use functions in forms.php lib
// Type: public
// Parameters: None
// Return Values: None
// Remarks:
// PHP performs better if you concatenate a large string
// and print it at the end as opposed to printing a lot.
// --------------------------------------------------------
function GenericForm()
{
$html = ""; // what we'll eventually print
$list = array(
"rms" => "Richard Stallman",
"linus" => "Linus Torvalds",
"graham" => "Paul Graham"
);
$input = $_GET; // change to $_POST, or a query out'd array based on your needs
$html .= StartForm($_SERVER['SCRIPT_NAME'], array("method" => "get"));
$html .= StartFormTable();
$html .= FormRow("Text Field",
TextField("text_field", $input['text_field'], 30));
$html .= FormRow("Text Area",
TextareaField("blob", $input['blob'], 80, 8, "hard"));
$html .= FormRow("Pulldown",
SelectField("developer_select", $list, $input['developer_select']));
$str = "";
foreach ($list as $key => $value) {
$str .= RadioField("developer_radio", $key, $value, $input['developer_radio']);
$str .= "
\n";
}
$html .= FormRow("Radio Buttons", $str);
$str = "";
foreach ($list as $key => $value) {
$str .= CheckboxField("developer_checkbox[]", $key, $value, $input['developer_checkbox']);
$str .= "
\n";
}
$html .= FormRow("Checkboxes", $str);
$html .= FormRow("Dates", DateForm("date", $input, "1995", "-2"));
$html .= FormRow("", SubmitField("", "Do Something"));
$html .= EndFormTable();
$html .= EndForm();
return $html;
}
?>