PEAR Manual
Prev | Chapter 41. HTML | Next

# HTML_QuickForm

The PEAR::HTML_QuickForm package provides methods for creating, validating, processing HTML forms.

## Introduction

QuickForm is a convenience library for dealing with HTML forms. It provides Javascript and server-side form validation, and is customizable and extensible in many ways. QuickForm consists of multiple files. The main file is `QuickForm.php` and should be installed in your `pear/HTML` directory. The other important files are `element.php`, which handles all methods relative to form elements, and `group.php`, which deals with methods relative to groups of elements in the form. Both are located in your `HTML/QuickForm` directory along with the other form objects. `input.php` contains a common class for all the elements of input type (text, password...). QuickForm has objects for all the common form elements: select, text, password, checkbox, file, submit, reset, button, image, radio, hidden, textarea. QuickForm provides the possibility to create your own elements as long as you comply with the common API.

## Creating a basic form

To be written.

## Classes representing form elements

To be written

### Base classes

### Standard HTML elements

### Custom elements

## Using groups

To be written.

## Working with elements' values

This section covers the methods QuickForm offers for managing form element's values and working with submitted values.

### Getting, setting and processing element values

### Validation and filters

QuickForm also provides validation rules support. You can code your own validation rules, register them in QuickForm and then call them in your script. By default, QuickForm can handle validation against regular expressions (preg_match style) and check for required elements. If you want client-side validation, QuickForm can generate the javascript code needed. Server-side validation is always on by default.

QuickForm can also make use of filters for data import into the form or for data processing once the form has been submitted. Filters work the same way as rules except that you don't need to register them. You write your filter functions and call them in your script. You can call any php function (ie. trim, addslashes, htmlentities, etc.) and have them applied recursively to your element values.

## Outputting the form

Your form can be customised in many ways. QuickForm can use different kind of renderers and provides a default one which allows for customization of the form, the elements, the error messages, the headers, the required elements note and the required elements sign. You can also write your own renderers.

### Form customization and output helpers

### Basic renderers

These renderers are based on pre-3.0 HTML_QuickForm code and require no external classes to do their work.

### Template-based renderers

These renderers use template engines to actually generate the HTML for the form.

### Renderer infrastructure

If you want to modify an existing renderer or write a new one, this section will be of interest to you.

Prev | Home | Next
Package HTML_Menu Constants | Up | HTML_QuickForm_Controller