Hi
This is a plan to start a discussion. A discussion that will end up
being a chapter in the Best practices part of the wiki. Well maybe not
a best practice, but certainly a "suggested method" :)
I'm writing a single form webapp that does this
A page that lists clients | runmode = list_clients
This page has a button to add a new client | runmode = show_client
calls edit_client
Each client has an edit button | runmode = show_client calls edit_client
Typically I like to have as few runmodes as possible, so edit_client
will look somewhat like this
sub edit_client {
if ($clientid eq '') {
CDBI::Clients->create();
} else {
$client = CDBI::Client->retrieve(id = $clientid);
$client->name('Fooboo');
$client->update
}
}
Now here are the beviours I need to handle
1: If this is a NEW client, then the first time the show_client form
is displayed the form fields should all be default
2: If this was a CURRENT client we should fill the page with that clients data
2: if there is an error while creating a new client, or updating an
old one, the form should reload with an error message, and the fields
should be populated with the erroneous data, so the user can correct
it, or click cancel.
Ideally I'd like to do this with only 3 runmodes and 2 templates,
that's just the way I'm used to doing things. I'm certainly open to
other ways of doing it... as there are or couse some issues with my
way of doing thigns that i've having troubles elegantly handling.
Cavaets:
If $clientid is never set, we can of course just keep filling
show_client up with HTML::FillInForm , using the $query object no
problem.
But if $clientid is set, the first time we process show_client we'll
want to populate it with database data, and every subsequent time
we'll want to populate it with query object data.
I guess I could just put a snip in there that says something like
<input type="hidden" name="second_submit" value="[% IF db_error
%]true[% END %]">
That would help in knowing which way to populate the form.
I guess that accuratly outlines my issue. I can put some sample code
on the net if that helps to illustrated my point.
I guess this may be a bit of a 2 parter, second part being
Do you folks have a method to easily populate a FillInForm object
[well query object more accuratly i guess] using
CDBI::Clients->retrieve .... maybe there is a translation module or
something.. I dunno.
Thanks folks.
--
Jeff MacDonald
http://www.halifaxbudolife.ca
http://www.nintai.ca
---------------------------------------------------------------------
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]