HTML_QuickForm Tutorial

In this tutorial I intend to cover some of the basic features of HTML_QuickForm, along with lots of examples to help you get to grips with how you can use it to simplify and speed up development of your forms.

A hello world example

We’ll start with a little form to ask for a users name, and then on submit, we’ll say hello! I’ll implemnt this in 2 ways. The first method is how HTML_QF is used in all the examples in the various documentation/examples I have seen, the second method is how I personally prefer to use it.

Method 1

Working example

Code

Method 2

Working example

Code

In all other examples on this tutorial, I will stick to this second method of using HTML_QuickForm, as this is my prefered method. Due to my laziness, only the second code example here has full comments explaining how this is working

A Signup Form

This example shows custom rules, and use of the ‘compare’ rule.

Working example

Code

A full-featured example

This example is taken from the documentation, and shows off a lot of what HTML_QF is able to achive.

Working example

Code

A form proprocessor

Using a form rule to do some pre-processing of the form... ish. This can be used to check server loads, or anything like that. This example will fail to process the form 50% of the time. Not so useful.

Working example

Code

A form that builds itself

Have a look at this page.

Using QuickForm renderers

I have constructed a demo page to show the output of a few of the array based HTML_QF renderers. Working example Other Resources The package homepage

A great tutorial on HTML_QuickForm