On Thursday 09 August 2007 1:47 pm, Mark Stosberg wrote:
> I process a lot of forms with CGI:::Application. It seems like the primary
> thing I do with it. The ::ValidateRM plugin is great, but it seems like I'm
> still writing the same patterns of code over and over, and things could be
> further simplified.
Yup, I'm with ya... I find that I'm also -regularly- coding the same patterns
over and over again. Works, but it could be simpler, I agree.
> I propose the following solution to improve things:
[.....snip.....]
> 2. If 'my_form' run mode does not exist, one is created like this:
>
> sub my_form {
> my $c = shift;
> my $errs = shift;
>
> my $t = $c->load_tmpl;
> $t->param($errs) if $errs;
> return $t->output;
> }
>
> That's the basic code to load a template that supports passing through
> the error messages like check_rm() expects.
My only concern with this would be that I use CAP::TT for all of my template
processing and would want to have a different (but equally consistent)
skeleton used instead.
> 3. We require 'my_form_profile' method to exist and return a DFV profile.
>
> 4. 'my_form_validate' is created for you with check_rm() functionality.
> This is where your form should submit. If the form validation fails, it
> does the check_rm() thing and returns the original form with errors
>
> 5. If the form validation succeeds, it forwards on to the "my_form_process"
> run mode.
[.....snip.....]
Sounds great. :)
> If you have a more complicated case, you can define your own 'my_form'
> subroutine and still use this module, or just fall back to
> using ::ValidateRM if you have even more specialized needs.
True, I could just define my own "my_form" method wherever I needed it so that
I could use CAP::TT instead. Obviously I'd like to get someone else to do
the heavy lifting for me, though (isn't that part of what hubris is about?).
Any thoughts on being able to make this skeleton either be replacable or to
segment the "my_form" method further so that it could take a different
template engine?
--
Graham TerMarsch
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]