Creating a form in "table mode" means that the
package returns the complete form in a fixed width table. Whilst
this does not work very well for most frontend websites, it is a
very convenient way to create forms during development phase or
for backend systems where the design does not matter (much).
require_once "HTML/Form.php";
$form = new HTML_Form($_SERVER['PHP_SELF']);
$form->addText("name", "What's your name?");
$form->addText("email", "What's your email address?");
$form->addPassword("password", "Please enter the desired password");
$form->addPlaintext("Tip", "Your password should be hard to guess");
$form->addSubmit("submit", "Submit");
$form->display();
This will display a table where the left column holds the labels of
the different fields. In the right column the different fields are
placed.
Displaying single form tags
Apart from retrieving the table as a whole, one can also use the
API of HTML_Form to
directly display single form tags.
require_once "HTML/Form.php";
$form = new HTML_Form($_SERVER['PHP_SELF']);
$form->displayText("name", "What's your name?");
The above example will print the HTML markup
being necessary to render a text input field. It will not print
the surrounding <form /> tag or something
else!
Returing single form tags
Similar to displaying form tags with the display*()
functions HTML_Form can also return the
tag instead of printing it.