[Catalyst] State of the art in form validation; opinion poll… Model based forms/validation?
Bill Moseley
moseley at hank.org
Wed Dec 5 04:38:11 GMT 2007
On Tue, Dec 04, 2007 at 05:47:27PM -0800, Ashley Pond V wrote:
> Putting the form profiles in YAML seems to work great (even though I
> hate the fairly ridiculous arrays of arrays grammar). For example:
>
...
>
> As crazy as it is, I like having it out of the code and into the
> config stuff.
Specifically into the config? Or just out of the controller?
I think it would not be hard to make any of the form systems use YAML
to read in their config, but when I've done that I find it quickly
gets too limiting for specifying validation.
> I'm leaning more and more to having *all* of this stuff defined
> (validation patterns, user messages for invalid input, clues for CGI
> fields) in the Model (DBIC; I love it and never find time to try
> Rose). Sort of a super phat Model. If it's not defined exclusively
> there, it ends up defined there (via schema), the controller,
> possibly the templates (messages), and even client-side in JS. I know
> I'm showing my tremendous grasp of the obvious when I say, this is
> just effing awful.
Again, I think you can only put so much in storage, so you need a
place for the form logic code that can't be represented in simple
regular expressions, ranges, etc.
The Rose form code is very cool. That's what I based my forms on.
I don't find automatic form markup creation that useful -- the forms
always seem to need customization. So, I generate the markup with
templates. So my forms end up looking like:
http://search.cpan.org/src/HANK/Catalyst-Plugin-Form-Processor-0.05/example/FormProcessor/root/templates/user/edit.tt
Here's an example of how my forms work in Catalyst:
http://search.cpan.org/~hank/Catalyst-Plugin-Form-Processor-0.05/lib/Catalyst/Plugin/Form/Processor.pm
http://search.cpan.org/~hank/Form-Processor-0.15/lib/Form/Processor.pm
--
Bill Moseley
moseley at hank.org
More information about the Catalyst
mailing list