Form

A framework for defining, validating and rendering HTML forms.

Overview

Form is at it's core a PHP class named Form. When making a form to use on a web page, you simply extend this class, and implement a method that returns an array describing the fields of the form. This field description, or field definition, specifies the names of the fields, their default values (if any), how they should be validated and how they should be rendered.

Form has built-in support for validation and rendering of most normal fields like text input, select dropdowns, radio buttons, checkboxes, textareas etc.

For special cases, Form is very flexible. It allows you to use custom callbacks for default values, validation and rendering, in several different ways. Check out the demos to see how to do it.

Unfortunately, there is no documentation written yet. However, the source is pretty well commented, and the demos should cover most normal uses and get you started.

License

Form is licensed under GPLv3/CC BY-NC-SA 3.0 (use whichever one you like).

Source code

The latest sources can be downloaded from Github.

Documentation

To be written..

Demos


Full source code for this file

<?php

require '../lib/form.php';

Tpl::$default_template_dir = dirname( __FILE__ ) . '/';

$ctxt = array(
	'source' => file_get_contents( __FILE__ ),
);

echo Tpl::create( 'layout.html.php', $ctxt )->
	wrapping( 'index.html.php' );