Saturday, May 14, 2011

Accessing other model not working

Parts hasMany Prices.
Parts belongsTo Prices

The idea is a part can have many prices but Part will have one Price
ID that will indicate the default price.

In the Prices controller, how would I go about updating the Parts
field? I searched around and it seems to be a common problem, but the
answers didn't get me anywhere.

One of my attempts that doesn't work.. this code is if the Price Add
form is submitted and the user indicated it was the default (prime):

$this->Part->id = $this->data['Price']['part_id'];
$partdata = $this->Part->read();
$partdata['Part']['prime_price_id'] = $this->Price->getLastInsertId();
$this->Part->save($this->data);

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate