The problem with an active group is that things slip quickly. Bumping this (just once) in case someone who can help didn't see it. I promise not to do it again. :-)
On Dec 17, 2:54 pm, Rob Wilkerson <[email protected]> wrote: > I have what I suppose is a 3-level model relationship. I have a > vendors table that is "extended" by a commercial_vendors table. A > commercial_vendor "is-a" vendor so the commercial_vendors table's > primary key is vendor_id which is also a foreign key referencing the > vendors table's id field. Additionally, all vendors of any "subtype" > have an address. Since other domain entities also have addresses, I've > normalized that data into its own table cleverly called "addresses". > The vendors table, then, has an address_id field that is a foreign key > referencing addresses.id. > > The key table structure looks like this: > > addresses > id (PK) > street_address_1 > ... > zip_code > > vendors > id (PK) > address_id (FK) > business_name > ... > created > updated > > commercial_vendors > vendor_id (PK,FK) > type > ... > > The model associations, in turn, are defined as: > > Address hasOne Vendor > Vendor hasOne CommercialVendor > CommercialVendor belongsTo Vendor > > I tried creating a relationship where Vendor belongsTo Address, but > when the scaffolding couldn't handle it (it errored trying to find > addresses.vendor_id, as I recall), I figured I'd done something I > shouldn't. > > Given all of that, I have my users creating a new commercial vendor > through /commercial_vendors/apply whose form action is / > commercial_vendors/add. When, in my CommercialVendor model, I try to > $this->CommercialVendor->saveAll ( $this->data ), I get a foreign key > error. Seems Cake can't save my Vendor because the foreign key to > addresses fails. Here's my form code in views/commercial_vendors/ > apply.ctp: > > <?php echo $form->create ( 'CommercialVendor' ) . "\n"; ?> > > <fieldset class="first"> > <legend>Applicant Information</legend> > > <?php > echo $form->input ( 'Vendor.business_name' ) . "\n"; > echo $form->input ( 'Address.street_address_1' ) . "\n"; > echo $form->input ( 'Address.street_address_2' ) . "\n"; > echo $form->input ( 'Address.city' ) . "\n"; > echo $form->input ( 'Address.state' ) . "\n"; > echo $form->input ( 'Address.zip_code' ) . "\n\n"; > > echo $form->input ( 'Vendor.applicant_title' ) . "\n"; > echo $form->input ( 'Vendor.applicant_first_name' ) . "\n"; > echo $form->input ( 'Vendor.applicant_last_name' ) . "\n"; > echo $form->input ( 'Vendor.email' ) . "\n"; > echo $form->input ( 'Vendor.phone_number' ) . "\n"; > ?> > </fieldset> > > <?php > echo $form->end ( > array ( > 'label' => 'Apply', > 'id' => 'commercial-vendor-save' > ) > ); > ?> > > Am I doing something wrong in my associations or am I asking more than > I should of saveAll()? I realize that there's no commercial vendor > info in the form. I'm trying to do this one step at a time so I can be > sure I understand the problems as they arise. > > Thanks for your time. > > Rob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
