perl-asp mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Chamas <j...@chamas.com>
Subject Re: $Request->{Form}
Date Mon, 10 Feb 2003 16:03:29 GMT
Philip Mak wrote:
> Is it all right to use $Request->{Form}? Directly using this variable
> seems to be an undocumented feature, but I found it useful recently:
> It makes $Response->{FormFill} more flexible because now rather than
> only being able to re-populate the form with data that the user just
> entered, I can also re-populate the form from a database record
> (useful for editing things in the database).
> 
> For example:
> 
> my $id = int($Request->Params('id'));
> my $submission = $dbh->selectrow_hashref("SELECT * FROM submissions WHERE id = $id");
> $Response->{FormFill} = 1;
> $Request->{Form} = $submission;
> # HTML code for the form goes below
> 

I would not recommend doing this exactly as you have done.  What I would
do rather is repopulate the $Form hashref, but keep the blessed object
reference as it, so:

   %{$Request->{Form}} = %$submission;

while its OK to access $Request->{Form} directly, what may not be OK
in the future is to change the class that that hash is blessed into.

Regards,

Josh

________________________________________________________________
Josh Chamas, Founder                   phone:925-552-0128
Chamas Enterprises Inc.                http://www.chamas.com
NodeWorks Link Checking                http://www.nodeworks.com


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Mime
View raw message