Hi David

I have followed through with these steps, but am still getting the same result. 
Here's my data array:

[ClinicProfile] => Array
        (
            [id] => 2
            [clinic_id] => 4df049cd-b4a8-4d8b-83b3-6ea5b59c8c28
            [description] => This is a test clinic description.
            [additional_information] => 
        )

    [Logo] => Array
        (
            [foreign_key] => 2
            [model] => ClinicProfile
            [group] => logo
            [file] => Array
                (
                    [name] => logo.gif
                    [type] => image/gif
                    [tmp_name] => /private/var/tmp/php3ASh1S
                    [error] => 0
                    [size] => 8349
                )

        )

...and the resulting row in attachments:

id      model   foreign_key     dirname basename        checksum        
alternative     group   created modified
1       2linicProfile   2       img     4e0b2cce88ddc.gif       
aee5e8c59fc6e529afb0f7832a4a4a24        NULL    2ogo    2011-06-29 13:46:54     
2011-06-29 13:46:54

Whilst we're corresponding, one of my objectives is that each ClinicProfile can 
have a single Logo and a single Picture. What's the best way of achieving this 
- or will it happen once the model and group fields are populated correctly?


Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 29 Jun 2011, at 12:38, David Persson wrote:

> 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

-- 
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

Reply via email to