Basic Tutorial - Step 1: Intro to FormBuilder Back

A Simple Form >>

Welcome to the FormBuilder Tutorial! This step-by-step tutorial will walk you through the usage of FormBuilder, from basic forms to advanced templates and multilingual messages. You can read these in series by clicking on the "Next" and "Previous" links, or skip directly to a topic using the navbar to the left.


FormBuilder is designed to handle all parts of a CGI form request - generation, submission, and validation. As such, FormBuilder applications will usually loop back on themselves. That is, you will have a single script that, when invoked, will take care of your entire application just based on the CGI parameters.

FormBuilder uses an Object-Oriented calling-style, but don't let that scare you away. Usage is exceedingly easy, as there are only a couple functions you need to know about. Throughout the documentation, our FormBuilder object will always be identified as $form, and you'll find this works equally well in your own scripts.

Here are the basic steps:

  1. Create a $form object with CGI::FormBuilder->new()
  2. Define your form fields with the $form->field() method.
  3. Check for whether the form was submitted with $form->submitted, and if so, validate it with $form->validate.
  4. Get to individual values using the $form->field() method, and do whatever you need to with the data (update a database, etc).
  5. If the form wasn't submitted (or fails validation), print it out using the main $form->render function.
That's all there is to it! FormBuilder will take care of HTML and JavaScript generation, table layout, validation, stickiness, error messages, and so forth. Let's look at a basic FormBuilder script.

A Simple Form >>