Hi,
I have a one-to-one relation between an Account and a User table, I'm trying to do all the pre-processing in the beforeSave
of the account model, but it seems like i can only change the values of $this->data['Account'][...]
and not $this->data['User'][...]
, why is so?
function beforeSave() {
// Check if this is a create or update action
if (empty($this->data['Account']['uid'])) {
$this->data['Account']['uid'] = uniqid();
$this->data['Account']['date_registration'] = date('Y-m-d');
$this->data['Account']['state'] = 1;
// this won't work
$this->data['User']['password'] = Security::hash($this->data['User']['password'], null, true);
}
return true;
}
Another question is what's the best way to check if the user is updating or creating the model in the beforeSave event, check for empty($this->data['Account']['id']))
?
Thanks.