Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Which HTML form builder

by roman (Monk)
on Jan 23, 2008 at 09:43 UTC ( [id://663764]=perlquestion: print w/replies, xml ) Need Help??

roman has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

which CPAN module do you use to build forms for your (catalyst powered) web pages?

CGI::FormBuilder? HTML::Widget? Something else?

Replies are listed 'Best First'.
Re: Which HTML form builder
by Rhandom (Curate) on Jan 23, 2008 at 15:45 UTC
    Qwerty.

    Any non-trivial - non-admin app that is user facing requires human design. I'm fine with using a form builder to create a template that is a good first stab - but after that you should really dump the static html to a file and edit it from there.

    After working in the web-apps arena for 10 years - and after having tried the dynamic page creation thing a few times, I have found that published models don't change all that often, and when they do editting the static HTML (or better yet handing it off to the in-house HTML designer) is just as easy as using a form-builder DSL. It also usually results in a more polished, user-friendly HTML page.

    Of course, if you are in one of those areas where a single database table actually happens to cover your entire model then the form builders are great. I don't remember the last time I had a user-facing (non-administrative) model that was simple enough to use a form builder with.

    I apologize that this wasn't a Perl solution to your problem. HTML/Javascript really should be part of your toolbox as a Software Engineer.

    my @a=qw(random brilliant braindead); print $a[rand(@a)];

      And CSS!

      Lazy man's form: With FormBuilder, I give each element a unique class and have a script that generates a basic style sheet based on FormBuilder's initial output. Then I go in emacs/TextPad and move things around as desired.

      Is the style sheet sillier looking than a hand-coded-from-scratch one? Sure is. But I treasure every minute I spend not coding forms. (Hate 'em, hate 'em, hate 'em.)

        I give each element a unique class

        You might be better off dropping this and using an id instead. This has a number of advantages.

        First, an id is supposed to represent a unique thing, whereas class is for groups.

        Second, in order to use label elements most effectively, you need to use a for attribute rather then nesting the control inside the label (this is due to the for approach having better support from browsers) - so you should have a unique id on each control anyway.

        (Hate 'em, hate 'em, hate 'em.)


        I would have to agree - I hate building forms too. It is somewhat tedious. But how long do you spend coding your form as opposed to the rest of the real work? I'd wager it is an insignificant amount of time - and future modifications are easier on the static HTML - and there are fewer processing cycles for static HTML - and you can give it to an HTML designer - and you can track insignificant changes via cvs/svn.

        As my wife likes to say - pick your battles.

        my @a=qw(random brilliant braindead); print $a[rand(@a)];

      I wonder about using something like FormFu as validation ... and as the “first stab at” cranking out a template. In other words, using it for what it's good for ... capturing the output thereof ... and changing it. Then, use it just for validation in the production code.

      Does that sort of thing work with FormFu? Am I sniffin' something really stinky here?

Re: Which HTML form builder
by memowe (Beadle) on Jan 23, 2008 at 15:32 UTC

    Hi roman,

    you want to read this article. I use FormFu with Catalyst and DBIC. I did'nt use any other form builder and i think, i never will have to. I think, it all fits together very nice.

    Regards, Mirko

      I recently went through this myself. I read a nice HTML::Widget example (Catalyst Tutorial) that I used to jump-start the project, but I found out HTML::Widget is no longer being developed. HTML::FormFu is the replacement that seems to be undergoing rapid development.

      Since FormFu was so new I tried out CGI::Formbuilder with Catalyst. I had successfully used it before with CGI::App. It has YAML configuration, easy validation both server side and javascript.

      I then found a nice article on FormFu in the advent Catalyst calendar, and decided to test it out since it seems to have a lot of momentum. My simple test worked well. One thing FormFu has going for it is the ability to work with database relationship when processing data. I don't have first hand experience with that aspect, but it looks promising to put together form components from multiple related tables.

      My experience with Data::FormValidator has been good. A bit of a learning curve to assembling the profile, but powerful enough to handle arbitrary validations.

      In summary, if I had to choose one I'd go w/ FormFu if I were more cutting edge and CGI::Formbuilder for the more conservative.

Re: Which HTML form builder
by Anonymous Monk on Jan 23, 2008 at 14:39 UTC
    FormValidator
Re: Which HTML form builder
by jonadab (Parson) on Jan 26, 2008 at 00:54 UTC

    I really don't get why people want a module for this. Maybe you can explain it to me...

    See, here's my thinking: with Perl's wealth of good quoting constructs (I tend to use qq myself, but some people prefer heredocs, whatever), constructing nice, clean, maintainable, wellformed, nicely indented, human-readable HTML is... very, very easy. Propagating the form elements with default values (taken, if desired, from form input) is very easy. A module to do this is, to my way of thinking, a solution in search of a problem. Indeed, it actually makes your job harder, because learning the XHTML needed to build forms is about five times easier than learning the interface to a module you've not used before, even if the module has a very nice clean easy-to-use interface (and many don't).

    Maybe you can explain your perspective to me: what is it about constructing HTML forms that makes you say, "Man, I wish I had a module for that"?

    -- 
    We're working on a six-year set of freely redistributable Vacation Bible School materials.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://663764]
Front-paged by vennirajan
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (1)
As of 2024-04-19 00:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found