[Catalyst] Re: HTML::FormFu and Rose::DB::Object?

Bill Moseley moseley at hank.org
Wed Apr 4 16:58:04 GMT 2007


On Wed, Apr 04, 2007 at 10:06:32AM -0400, John Siracusa wrote:
> The idea with RHTMLO is to build up a library of reusable (and potentially
> complex) widgets.  Make that date picker once, according to a agreed upon
> design and function for your current project (or entire company), and then
> reuse it anywhere as easily as any other "simple" widget:
> 
>     $form->field('start_date')->xhtml
> 
> which might produce:
> 
>     +-------+  +----+  +--------+
>     | Jan v |  | 12 |  | 2007 v | [c]
>     +-------+  +----+  +--------+
> 
> That is, a pop-up for month, a text field for day, and a pop-up for year,
> plus a [c] calendar pop-up icon.

Cool stuff.

Another approach I have taken is to have a widget library defined in a
template.  I then use macros to display the form elements
individually:

    [% field( 'Event Start Date', 'start_date' ) %]

And the widget library determines how to generate the html,
where to put the little calendar icon, set a class tag so
javascript can find it in the DOM, and include the required
javascript.

Not sure there's any advantage to that way, though.  RHTMLO spits out
html that's easy enough to style with CSS.  Plus, it's likely anyone
that can dive into the template widget library probably could dive
into Perl as well.

It does give you that warm feeling knowing there's not a lick of html
in the application code. ;)

But, it does have an advantage that, say, error messages associated
with a field can be rearranged easily in the widget template by the
html person.  Although, I suppose even that can be easily done
with CSS.

I also tend to have blocks of template code to build up parts of forms
that can be used by more than one form. Something like:

[% BLOCK personal_info %]
    <fieldset>
            <legend>Your Personal Info</legend>
            [%
                field('First Name',    'first_name' );
                field('Last Name',     'last_name' );
                field('Email',         'email',
                    'This is required so we can send you promotional spam' );
                field('Contact Phone',  'phone',
                    'Required so we can follow up why you didn't
                    respond to the spam we sent by email' );
            %]
    </fieldset>
[% END %]




-- 
Bill Moseley
moseley at hank.org




More information about the Catalyst mailing list