[Catalyst] An initial version of a form rendering and validation module

Andrew Ford A.Ford at ford-mason.co.uk
Tue Nov 22 17:02:23 CET 2005


John Lifsey - Contractor - wrote:

> It may be covered by your callback idea, but if I were using it I'm 
> sure I would want to arrange the form how I liked (or more correctly, 
> someone with a clue about interface would arrange it). Would something 
> like this be possible?
>
> [% form.start %]
>    <table><tr><td>Your email address:</td><td>[% form.email 
> %]</td></tr></table>
> [% form.stop %]
>
> So that formmanager (gener/valid)ates the form elements, but the 
> structure can be changed?


The CGI::FormManager::Form package has two default TT2 templates - one 
for the fill-in form (with or without error messages) and the other for 
the confirmation form, however you can specify your own templates:

   my $fmgr = CGI::FormManager->new({}, { template => $mytemplate,
                                                                           
confirm_template => $myconfirmtemplate });
   # add a form using our own templates
   my $form1 = $fmgr->form(myform1 => { elements => [ .. ] } );
   # add another form using another pair of templates
   my $form1 = $fmgr->form(myform2 => { elements => [ .. ],
                                                                        
  options => { template => $mytemplate2,
                                                                        
                        confirm_temlate => ... } );

The other thing is that the elements of the default templates are 
labelled with classes, so that you should be able to adapt the styling 
quite precisely using CSS.

Of course there are issues like the ordering of fields and literal text 
within the form that might be up for discussion between the interface 
designer and the programmer, and this module sticks such things in the 
code.  Maybe I could separate out the definition of the form fields, and 
the definition of the ordering of the fields within the form.  I'll 
think about this.

Regards
Andrew



More information about the Catalyst mailing list