I'm trying to update a row on my profiles
table to reset a users profile picture to the default of user.png
. I have the following action in my controller:
public function deleteProfilePicture() {
$this->layout = 'ajax';
// First find the profile ID from the user ID
$profileId = $this->Profile->find('first', array(
'condition' => array('User.id' => $this->Auth->user('id')),
'fields' => array('Profile.id'),
'recursive' => -1
));
$this->Profile->id = $profileId['Profile']['id'];
$this->Profile->saveField('picture', 'user.png', false);
}
However, when I request the URL (/profile/deleteProfilePicture
) I get no errors but the database row isn't updated. I have made sure the current profile ID is used by using debug($profileId)
.
What could be going wrong here?
Edit: The return value of saveField()
:
array(
'Profile' => array(
'id' => '36',
'modified' => '2013-04-05 14:16:57'
)
)