It sounds to me like you want Client and Vendor (for example) and Employee (as another example) all to store their associated phone numbers (mobile, home, etc) in a single model called Phone.
-- If this is correct, when saving a record in Phone, you would need to know which model the record is associated with. You say "but not sending the data via post". Well how are you sending it? At the very least you would need to know the primary key (usually "id") of the Client, Vendor or Employee when you generated the form. Pass the model into the form (from the controller) and pass it back as a hidden field (either GET or POST). I think you would then need to store the owner model name (Client, Vendor...) as another field in you Phone model.
It also seems you would need a field called something like "parent_id" in the Phone model to save the primary key of the record to which the Phone record belongs. Look at "foreign_key" examples here:
http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html
Yours might look something like:
class Client extends AppModel { public $hasMany = array( 'Phone' => array( 'className' => 'Phonr', 'foreignKey' => 'parent_id', ) ); }
But then again, maybe I don't understand your problem.
Ken
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment