[Catalyst] Catalyst FormBuilder plugin on CPAN
Nate Wiger
nwiger at scea.com
Thu Aug 17 02:14:42 CEST 2006
All-
I just now uploaded Catalyst::Plugin::FormBuilder to CPAN, which adds
support for FormBuilder in Catalyst. It's also available here:
http://www.formbuilder.org/download/Catalyst-Plugin-FormBuilder-1.02.tar.gz
Usage is similar to XMLRPC: for those controller methods that contain
forms, simply associate a ":Form" attribute with them:
package MyApp::Controller::Books;
sub edit : Form {
# this automatically loads root/forms/books/edit.fb
# and creates a $c->form object for you
$c->form->method('post');
$c->form->messages('messages.fr'); # French errors
}
The page rendering is handled for you by Catalyst using its Template
Toolkit hooks. To get a standard form, just call form.render in your
template:
<!-- root/src/books/edit.tt -->
[% form.render %]
Or, if you want finer control over the placement of your fields, you can
directly render your form using FormBuilder methods:
<head>[% form.jshead %]</head>
[% form.start %]
<table>
[% FOREACH field IN form.fields %]
<tr valign="top">
<td>
[% field.required
? "<b>$field.label</b>" : field.label
%]
</td>
<td>
[% IF field.invalid %]
Missing or invalid entry, please try again.
[% END %]
[% field.tag %]
</td>
</tr>
[% END %]
<tr>
<td colspan="2" align="center">
[% form.submit %] [% form.reset %]
</td>
</tr>
</table>
[% form.statetags %]
[% form.end %]
Thanks for Catalyst, it's great! And it was extremely easy to get
FormBuilder plugged in. I'm a convert. (If anyone has suggestions on the
plugin, please let me know).
Cheers,
Nate Wiger
FormBuilder Author
www.formbuilder.org
More information about the Catalyst
mailing list