--- Tony Bowden <tony-cdbitalk at kasei.com> wrote:
> On Wed, Nov 03, 2004 at 02:34:10PM -0800, Peter Speltz wrote:
> > For an example: I have one big employee form with person, usr, and employee
> > fields. employee has a prsn and usr. So i want to say something like
>
> There's been talk a few times of having Class::DBI's normal create() be
> able to take arguments for related classes as well, and do the right
> thing. Nothing's really ever come of it, but if it did, then this may
> help with your problem (rather than trying to handle it in
> create_from_cgi itself).
Don't you think that would be useful in create_from_cgi?
Here's a typical example of how it would be useful. I'll take a crack at coding
it RIGHT AWAY if you think it would have a chance of making it in the distro as
i need this functionality all the time.
A user of the system is adding a new customer. the customer has a user_id field
to tell who entered that customer. (Say the mean boss wants to put a stop to
people entering data in the wrong format so he's tracking who enters what.)
The user_id is known in the session and not a field in the form. We could add
hidden usr_id field to the form but that doesn't work in cases like my first
example where the foreign object must be created first and that's stupid
anyway.
So, the ideal solution would be to add an additional field to the
create_from_cgi which would allow you to use it like this:
my $customer = Customer->create_from_cgi( $h => { additional => {user_id =>
$session->usr_id} } );
Then you get the power of FromCGI with the freedom of CDBI::create. The docs
would change like so:
$film->update_from_cgi($h => {
all => \@all_columns, # auto-filled if left blank
ignore => \@cols_to_ignore,
required => \@cols_needed,
additional => \%cols_and_values_not_in_form
});
=====
pjs
__________________________________
Do you Yahoo!?
Check out the new Yahoo! Front Page.
www.yahoo.com
_______________________________________________
maypole mailing list
maypole at lists.netthink.co.uk
http://lists.netthink.co.uk/listinfo/maypole
This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:57 GMT