I'm trying to load
, edit
and save
a record with CakePHP 2.0
but I get a generic error
during the save
method that don't help me to understand where is the problem.
if I try with debug($this->User->invalidFields());
I get an empty array
, but I get false
from $this->User->save()
condition.
Here is the controller action where I get the error:
public function activate ($code = false) {
if (!empty ($code)) {
// if I printr $user I get the right user
$user = $this->User->find('first', array('activation_key' => $code));
if (!empty($user)) {
$this->User->set(array (
'activation_key' => null,
'active' => 1
));
if ($this->User->save()) {
$this->render('activation_successful');
} else {
// I get this error
$this->set('status', 'Save error message');
$this->set('user_data', $user);
$this->render('activation_fail');
}
debug($this->User->invalidFields());
} else {
$this->set('status', 'Account not found for this key');
$this->render('activation_fail');
}
} else {
$this->set('status', 'Empty key');
$this->render('activation_fail');
}
}
When I try the action test.com/users/activate/hashedkey
I get the activation_fail
template page with Save error message
message.
If I printr
the $user
var I get the right user from cake's find
method.
Where I'm wrong?