Perl Form Builder ::Features ::Download ::Tutorial ::Examples
::Documentation ::FormBuilder Google Group ::Old List Archives ::Contribute
Note: The mailing list is has been replaced by the Google FormBuilder Group


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


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


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

Intermediate Tutorial - Step 4: CGI Stickiness Print

<< Default Values | JavaScript Actions >>

"Stickiness" is the ability of values to remain filled in across submissions. Everyone's filled out a form that has an error, and which must be corrected. In such applications, if they're coded right, then the fields that have already been filled in remain filled in.

However, normally this is a big pain for anything other than simple text fields. Getting a select list to remain sticky is tedious at the very least, and multiple-select lists are error-prone because you have to calculate an intersection of the options and values.

As mentioned before, FormBuilder automatically handles stickiness for you, overriding any default values you may have specified, and returning the correct data to you. However, sometimes you may not want stickiness. For example, you may want to write an app that allows a person to add multiple entries to a database in rapid succession. In this case, simply turn stickiness off:

$form = CGI::FormBuilder->new(
             fields => \@fields,
             sticky => 0          # not sticky
You will still be able to get to what the person entered via the field() function, but it won't appear in the form after being submitted.

On the other hand, you may decide it would be nice to pre-fill certain fields in a form from an HTML link. For example, if a person clicks on "Create new membership", you may want to fill in the name of the site. This is especially useful if you host several websites and want to use one form.

This is exceedingly easy in FormBuilder. Since FormBuilder automatically handles stickiness, simply list any fields and values you want filled in via a URL request:

Then, assuming that subscribe.cgi had a "site" and "bill" field in its form, they would be automatically filled in and/or selected with the specified data.

<< Default Values | JavaScript Actions >>

FormBuilder is © Nate Wiger, with contributions from many people.