Hi Marco, You did the right thing with changing the format of $this->data, because the hasOne Relationship needs it to be in that format.
What kind of validation error do you get? -David On 18 Jun., 12:42, byqsri <[email protected]> wrote: > is here someone can help me? > > On 15 Giu, 16:52, "[email protected]" > > <[email protected]> wrote: > > Hi > > I try to use MediaPlugin of David Persson. > > I have installed it I config it but when I tr8y test it using > > documentation (http://wiki.github.com/davidpersson/media/attachment- > > model ) but It doesn't work (the plugin doesn't save the attachment). > > My situation is: > > I have User model with : > > > var $hasOne = array( > > 'Photo' => array( > > 'className' => 'Media.Attachment', > > 'foreignKey' => 'foreign_key', > > 'conditions' => array('model' => 'User'), > > 'dependent' => true, > > ) > > ); > > > In my controller I have: > > > $this->data = array( > > 'User' => array( > > 'id' => 1 > > ), > > 'Photo' => array( > > 0 => array('file' => > > 'http://cakephp.org/img/cake-logo.png', > > 'model' => 'User') > > ) > > ); > > > $this->User->saveAll($this->data, array('validate' => > > 'first')); > > > $this->data seems strange if I read from cake documentation > > (http://book.cakephp.org/view/75/Saving-Your-Data) > > But if I set : > > > $this->data = array( > > 'User' => array( > > 'id' => 1 > > ), > > 'Photo' => array( > > 'file' => > > 'http://cakephp.org/img/cake-logo.png', > > 'model' => 'User' > > ) > > ); > > I get an validation error from plugin > > I hope someone can help me > > Many Thanks > > Marco > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
