::Features ::Download ::Tutorial ::Mailing List ::Docs ::Examples ::Contribute
 

Basic
1. Intro to FormBuilder
2. A Simple Form
3. Form Method
4. Input Validation
5. Field Options
6. Multi-Select Lists
7. Field Data
8. Field Attributes
9. HTML Formatting
10. Custom Headers
S. Summary

Intermediate
1. Trickier Forms
2. Perl References
3. Default Values
4. CGI Stickiness
5. JavaScript Actions
6. Input Validation 2
7. Multiple Submits
8. JavaScript Actions 2
9. Modules & mod_perl
10. Smartness
S. Summary

Advanced
1. Remaining Features
2. Intro to Templates
3. HTML::Template
4. HTML::Template 2
5. Template Toolkit
6. Exploiting render()
7. Multi-Screen Apps
8. Multi-Screen Apps 2
9. Multi-Screen Apps 3
10. Custom Messages
S. Summary

Basic Tutorial - Step 1: Intro to FormBuilder

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 at the bottom, or skip directly to a topic using the navbar to the left.

Basics

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.

Heck, I'm a sysadmin not a programmer myself, so if I can use it, so can you! :-)

Using FormBuilder amounts to these high-level steps:

  1. Decide what fields your form will have.

  2. Create a $form object with CGI::FormBuilder->new(), specifying your fields using the fields option.

  3. Make any individual changes to your fields with the $form->field() method.

  4. Check for whether the form was submitted with $form->submitted, and if so validate it with $form->validate.

  5. If the data passes validation, get to individual elements using the $form->field() method, and do whatever you need to with the data (update a database, etc).

  6. 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.

Next: A Simple Form

FormBuilder is © 2001-2003 Nathan Wiger, with contributions from many people.