Just using FormBuilder, aka the Perl CGI::FormBuilder module, for the first time in a project.
FormBuilder with DBI and CGI::Session is similar to Ruby on Rails for Perl for CRUD apps. You get HTML form creation, input stickiness, javascript validation and server-side validation for “free.”
By itself, FormBuilder is suitable for rapidly prototyping web applications for internal use.
After adding HTML::Template files, you can do professionally-polished web applications.
Some things to keep in mind when combining FormBuilder with HTML::Template:
- ensure you use FormBuilder’s form-start, js-head and form-submit tags in each template, or nothing will seem to work
- the default select menu text is “–select–“. Pass the ‘selectname’ argument to change the text to something like ‘Choose Plan’.
- Pass a hash reference to ‘select’ to specify both options and values. Use numbered values to control ordering.
- Pass ‘value’ to checkbox to pre-select it.
- Suppress checkbox text labels by passing a hash reference with empty strings for values.
- The source code for field controls is in /usr/local/share/perl5/CGI/FormBuilder/Field/. Although it’s very terse Perl, I found it useful for understanding the select field control.
- if your submit buttons are touching each other, add this to a stylesheet:
.fb_button { margin-right:5px; }
- the way I conditionally show some form fields within the same form is to omit the field names from the new(require) call and instead use field(require) on each, and use a class called my_fb_hide in my template on those fields as appropriate.
.my_fb_hide { display:none; visibility:hidden; }
The best online reference I’ve found is this page.
To evaluate FormBuilder for your needs, I’d recommend doing a simple form first, then trying to implement your most complicated form. That should reveal if it gives you the level of control you need.
The author recommends using FormBuilder 3.08 or higher, but my testing on 3.05 worked fine for me.
FormBuilder has minimal dependencies (almost none), so it is much easier to install than Catalyst.