I have a Profile model with a hasOne relationship to a Detail model. I have a registration form that saves data into both model's tables, but I want the username
field from the profile model to be copied over to the
username
field in the details model so that each has the same username
.
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'));
}
}
}
This code in my Profile controller gives me the error:
Undefined property: Profile::$username
Any ideas?