[Catalyst] Re: HTML::FormFu and Rose::DB::Object?
quinn at fairpath.com
Wed Apr 4 04:53:32 GMT 2007
Peter Karman wrote:
> Quinn Weaver scribbled on 4/3/07 12:40 PM:
> > If so, will FormFu be compatible with Rose::DB::Object, or will it be
> > tied to DBIC? (I know the Rose framework has its own way of handling
> > forms, but I like FormFu better because of its clean separation of
> > concerns.)
> > Any words of wisdom from the FormFu masters? :)
> I'm no master, nor have I looked at FormFu. However, I'd suggest you look at the
> Catalyst::Controller::Rose stuff I posted to CPAN last week:
I have, and I'm using it now, but not the parts that are tied to RHTMLO.
I agree that Catalyst::Controller::Rose::CRUD is a good place to start
this. I was just hoping that maybe the FormFu people were already
doing that work for me. ;)
> That said, what exactly is it about RHTMLO that strikes you as less than a
> "clear separation of concerns"?
Well, it doesn't let you construct the form piece-by-piece in your TT
template the way Catalyst::Controller::FormBuilder and CGI::FormBuilder do
(see the FormBuilder POD extract at the end of this post).
In contrast to FormBuilder, RHTMLO wants you to write your HTML form
by calling Perl methods, somewhat in the spirit of CGI.pm. This makes
it hard for design people to edit the form.
(I use FormBuilder as an example because HTML::FormFu, as I understand
it, will follow a similar model. This post seems to confirm that:
Also, Catalyst::Controller::FormBuilder accepts YAML as input,
whereas RHTMLO depends on Perl. (Again, see below for a sample.) YMMV,
but the design people here are relatively comfortable editing YAML and
quite uncomfortable editing Perl code.
So those are, to me, cases of sub-optimal separation of concerns.
On the other hand, I guess it is possible with RHTMLO to take the
generated (X)HTML and plunk it into a TT template. The rest of
This does mean, however, that the design people have to come to you,
the programmer, if they want changes to the form--e.g. if they want
to change the contents of a <div> or, if, in plain HTML land, they want
to change the type of an <input>. (Obviously the problem is ameliorated
in XHTML, since they can change some stuff using CSS.) You can imagine
As you can see, my main goal is to support the common division of labor
between XHTML (etc.) design and back-end coding. That's what I have
in mind when I think separation of concerns.
I'm still searching for the right solution, but RHTMLO seems a little
worse in this department than FormBuilder. Or am I missing something?
=) Maybe with clean XHTML it doesn't matter. Maybe. I'm slated soon
to run this idea by my client's design people and see what they think.
Many thanks for your input so far, and for posting your Rose/Catalyst modules.
Sample YAML for a Catalyst::Controller::FormBuilder form:
label: Descriptive Text for the Foo
submit: Update Foo
Snippet from Catalyst::Controller::FormBuilder POD:
From within your template, you can reference any of FormBuilder
you might want exact control over fields, rendering them in a "<div>"
instead of a table. You could do something like this:
<!-- root/src/books/edit.tt -->
<title>[% formbuilder.title %]</title>
[% formbuilder.start -%]
[% FOREACH field IN formbuilder.fields -%]
<span [% IF field.required %]class="required"[%END%]>[%field.label%]</span>
[% field.field %]
[% IF field.invalid -%]
Missing or invalid entry, please try again.
[% END %]
[% END %]
<div id="submit">[% formbuilder.submit %]</div>
<div id="reset">[% formbuilder.reset %]</div>
[% formbuilder.end -%]
Quinn Weaver, independent contractor | President, San Francisco Perl Mongers
http://fairpath.com/quinn/resume/ | http://sf.pm.org/
More information about the Catalyst