Tuesday, February 28, 2012

Media PLugin

I'm using David Persson's media plugin. I have a users table that
contains the fields necessary to link to an image file, but a user
does not have to have an image. When I include the Media.Coupler
behaviour in the User model User->create always fails on User->save
when the user does not have an image because of the beforeSave in
coupler.php:

function beforeSave(&$Model) {
if (!$Model->exists()) {
if (!isset($Model->data[$Model->alias]['file'])) {
unset($Model->data[$Model->alias]); <<<--- clears down my User
data
return true;
}
} else {

This is unsetting the User data because the file key is missing. If I
comment out the unset my User->save is successful. The Media.Coupler
is working perfectly well for another table that hasMany images in an
associated table.

Is there a setting I need to configure or am I doing something else
wrong?

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: