Wednesday, June 24, 2009

Re: Problem with Media Plugin of David Persson

Many Thanks
Now it works.
I have a question:
Can I set the vary validation rules inside the model User inside the
association:

var $hasOne = array(
'Photo' => array(
'className' => 'Media.Attachment',
'foreignKey' => 'foreign_key',
'conditions' => array('model' => 'User'),
'dependent' => true,
)
);

Because I can have different rules in according to which is the
attachment to upload
Many Thanks
On 22 Giu, 18:35, davidpersson <davidpers...@gmx.de> wrote:
> Have a look at the Attachment Model's validation property.
>
> To make http transfers work you must explicitly allow all http
> transfers by specifying 'http://' in the location validation rule or -
> if you only want to allow transfers from certain domains - use 'http://
> example.org' instead.
>
>   var $validate = array(
>     'file' => array(
>       // ...
>       'location' => array('rule' => array('checkLocation', array
> (MEDIA_TRANSFER, '/tmp/', 'http://'))),
>       // ...
>       )
>     ));
>
> On 22 Jun., 12:00, byqsri <marco.rizze...@gmail.com> wrote:
>
> > This is the $validationErrors:
>
> > Array
> > (
> >     [Photo] => Array
> >         (
> >             [file] => location
> >         )
>
> > )
>
> > On 20 Giu, 15:36, davidpersson <davidpers...@gmx.de> wrote:
>
> > > 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 <marco.rizze...@gmail.com> wrote:
>
> > > > is here someone can help me?
>
> > > > On 15 Giu, 16:52, "marco.rizze...@gmail.com"
>
> > > > <marco.rizze...@gmail.com> 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: