Hello,

I am using RDBO in conjunction with Rose::HTML::Form for the first time, and
wonder if there are any guides or examples out there showing some
conventional integration techniques.  Specifically, how best to use RHF's
objects returned by object_from_form() style methods to update database
rows.  Currently I have something like this:

 $form->init_with_customer($session->customer);  # is a load()ed RDBO
object
 if ($ENV{REQUEST_METHOD} eq 'POST') {

   $form->params(\%ARGS);
   $form->init_fields();

   if ($form->validate) {
     my $c = $form->customer_from_form;  # is RDBO::Customer->new()
     $c->id($session->customer_id);  # avoid an insert
     $c->save(update => 1, changes_only => 1, cascade => 1); # force an
update
   }
 }

Which works, but seems like there is probably a more conventional way to do
this.  But my real problem comes when my form returns other objects as well,
which are related to customer ($c) . . .for example


   if ($form->validate) {

     my $c = $form->customer_from_form;  # is RDBO::Customer->new()
     $c->id($session->customer_id);  # avoid an insert

     my $a = $form->address_from_form;  # is RDBO::Address->new()
     $c->billing_address($a);

     # inserts a new RDBO::Address record, but unfortunately I want an
update
     $c->save(update => 1, changes_only => 1, cascade => 1);

   }


Is there a better way to use these two packages together?


Thanks in advance,
DW
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to