logo       
Google Custom Search
    AddThis Social Bookmark Button

Re: A new way to do form processing: msg#00194

Subject: Re: A new way to do form processing
One of the things that I've come around to implementing is to push the
form validation stuff into the templates, as opposed to the runmode
code, for workflow reasons.

My big reason for doing this is to allow the people who develop
templates, who are separate from people developing runmodes in many
instances, to have the flexibility to decide how things get validated
and how they don't.  In many cases around here, the person writing the
templates is not a programmer per se, and so it is nice for him to be
able to do validation without having to involve one of us who is.

To make all this work, I have set up a structure for forms that
requires a few hidden fields:

form - the name of the runmode used to display this form.
rm - the name of the runmode used to display if the form submission is
successful
formHandler - the name of the method used to deal with the form, if
the form is valid

cgiapp_prerun checks for 'form' in the params.  If it is there, then
it hands processing off to a method called (oddly enough) validate,
which does some Data::Formvalidator parsing to figure out if things
look right or not.  If they do, it cedes control over to the method in
formHandler.  If not, it fills in the appropriate error slots and
returns the original form runmode.

This, in effect, lets me build strict display runmodes, and methods
that only handle form submission.  It allows the re-use of form
submission methods if need be, as they don't do any display work.

I've stuffed all of this functionality into a subclass of CGI::App,
which I then further subclass.

Works out fairly well.

-- 
caleb
http://www.ruejulesverne.com

On Fri, 22 Oct 2004 13:04:01 -0400, Jason Purdy <jason@xxxxxxxxxxxxxxxx> wrote:
> Maybe I'm missing something and it's probably a personal preference, but
> I enjoy separating all those runmodes (one for display and another for
> processing).  My forms also submit to themselves, but they have a hidden
> runmode parameter to go to the processing runmode directly.
> 
> Essentially, you also have two runmodes, but contained in one with that
> if branch.  And then you want to do more work to automatically separate
> them out?
> 
> It sounds like you're doing a lot of work to get somewhere that cgiapp
> is at already.
> 
> Jason
> 
> 
> 
> ---------------------------------------------------------------------
> Web Archive:  http://www.mail-archive.com/cgiapp@xxxxxxxxxxxxxxxxx/
>               http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
> To unsubscribe, e-mail: cgiapp-unsubscribe@xxxxxxxxxxxxxxxxx
> For additional commands, e-mail: cgiapp-help@xxxxxxxxxxxxxxxxx
> 
>

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/cgiapp@xxxxxxxxxxxxxxxxx/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: cgiapp-unsubscribe@xxxxxxxxxxxxxxxxx
For additional commands, e-mail: cgiapp-help@xxxxxxxxxxxxxxxxx





Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>