Hey,
Thanks a lot for the information. This is really helpful and a prime example
of giving good debugging information.
The problem is with that you're mixing different configuration scenarios
with the models and therefore also having your data structured incorrectly.
What you actually want is a central Attachment model:
1. If you haven't done already copy the Attachment model file from the media
plugin into your app.
2. Modify it so that it extends AppModel.
3. As you're now using the Attachment model in your app you'll need to
modify the hasMany propetry of the ClinicProfile model ('class' =>
'Media.Attachment' to just 'class' => 'Attachment').
4. Move what you have for actsAs, media related validation rules,
transferTo() and beforeDelete() from the ClinicProfile into the the
Attachment model, but leave hasMany in ClinicProfile.
Now modify the form so that in the corresponding action your data before it
gets saved is structured like this:
$this->data = array(
'ClinicProfile' => /* ... */,
'Logo' => array('file' => /* here goes the upload array */, 'model' =>
'ClinicProfile', 'group' => 'logo')
);
$this->ClinicProfile->saveAll($this->data, array('validate' =>'first'));
And you should be done!
- David
P.s.: You might also want to look at
http://book.cakephp.org/view/1031/Saving-Your-Data for the data structuring
part.
P.p.s.: Sorry for the two mails the second one was directed at the other
Jeremy ;)
--
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
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php