I have been using the Media Plugin by David Persson and I think it's great and has saved me a lot of time. I started out with an Invoice model that hasMany Attachments and everything worked well. I then added Materials to my invoice and tried added Attachments to a specific material associated with the Invoice. The extra attachment is read at the server and saved, but it is saved with the invoice_id, not the specific material item on that invoice. Here is my data array as it arrives at the server, via my iPhone app.
[Invoice] => Array ( [project_id] => 2 [invoice_date] => 2011/10/01 [is_approved] => 1 ) [InvoicedMaterial] => Array ( [0] => Array ( [description] => Diesel Fuel [amount] => 20 [unit_of_measure] => Gallons ) ) [Attachment] => Array ( [0] => Array ( [model] => InvoicedMaterial [alternative] => Diesel Fuel [file] => Array ( [name] => Diesel Fuel [type] => image/jpeg [tmp_name] => /tmp/phpP7Qy7k [error] => 0 [size] => 901352 ) ) [1] => Array ( [model] => Invoice [alternative] => Signature [file] => Array ( [name] => 023C1C3D-B63F-442E-87DE- FC3D270D8740 [type] => image/png [tmp_name] => /tmp/phpkhczsG [error] => 0 [size] => 5953 ) ) ) [InvoicedLabor] => Array ( [0] => Array ( [description] => Construction Foreman [amount] => 10 [unit_of_measure] => hrs ) ) ) My models are setup as follows: Invoice: var $hasMany = array( 'InvoicedEquipment' => array( 'className' => 'InvoicedEquipment', 'foreignKey' => 'invoice_id', 'dependent' => false, 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => '' ), 'InvoicedLabor' => array( 'className' => 'InvoicedLabor', 'foreignKey' => 'invoice_id', 'dependent' => false, 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => '' ), 'InvoicedMaterial' => array( 'className' => 'InvoicedMaterial', 'foreignKey' => 'invoice_id', 'dependent' => false, 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => '' ), 'Attachment' => array( 'className' => 'Media.Attachment', 'foreignKey' => 'foreign_key', 'conditions' => array('Attachment.model' => 'Invoice'), 'dependent' => true, ) ); InvoicedMaterial: var $hasMany = array( 'Attachment' => array( 'className' => 'Media.Attachment', 'foreignKey' => 'foreign_key', 'conditions' => array('Attachment.model' => 'InvoicedMaterial'), 'dependent' => true, )); I'm passing all of the attachments as one array, based on the plugin "recipes" documentation, but that doesn't seem right. Can the media plugin handle a nested form being posted and figure out which attachment should be associated with which model? -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php