PHP Class for Generating HTML Forms

The PHP Form Class is a lightweight, flexible class for generating (X)HTML forms. Its features include:

  • Methods for generating common form elements such as inputs of all types, text areas, select lists, and more.
  • Support for HTML5 input types.
  • Capability to add any attribute, including custom attributes, to any element using associative array syntax.
  • Generic functions that allow you to add elements of any type, including fieldset, legend, div, span, and paragraph elements for containing your form elements.
  • A property setting that allows you to specify XHTML syntax for closing empty tags and expanding minimized or boolean attributes.

Demo, Download, Documentation, and More

View the PHP Form Class file as well as an example demonstrating its use. A download file includes the PHP Form Class file and an example. Documentation is also provided.

See the PHP Table Class which is well suited for use with the PHP Form Class. See also the PHP Order Form for a demonstration of the PHP Form Class used in combination with the PHP Table Class.