У меня есть модель Profile с отношением hasOne к модели Detail.У меня есть форма регистрации, которая сохраняет данные в таблицы обеих моделей, но я хочу, чтобы поле username
из модели профиля было скопировано в поле
username
в модели сведений так, чтобы у каждого был один и тот же * 1004.*.
function new_account()
{
if(!empty($this->data))
{
$this->Profile->modified = date("Y-m-d H:i:s");
if($this->Profile->save($this->data))
{
$this->data['Detail']['profile_id'] = $this->Profile->id;
$this->data['Detail']['username'] = $this->Profile->username;
$this->Profile->Detail->save($this->data);
$this->Session->setFlash('Your registration was successful.');
$this->redirect(array('action'=>'index'));
}
}
}
Этот код в моем контроллере профиля выдает мне ошибку:
Undefined property: Profile::$username
Есть идеи?