0
세부 모델과 hasOne 관계가있는 프로필 모델이 있습니다. 두 모델의 테이블에 데이터를 저장하는 등록 양식이 있지만 세부 모델의
username
필드에 복사하여 각각 username
이되도록 프로필 모델의 username
필드를 복사해야합니다.양식의 데이터 필드를 두 모델의 두 열로 저장하려는 경우
Undefined property: Profile::$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-> Profile-> modified = date ("Y-m-d H : i : s");는 예상대로 작동하지 않습니다. 대신에'$ this-> data [ 'Profile'] [ 'modified']'에'date ("Y-m-d H : i : s")'의 반환 값을 할당해야 할 것이다. – Mike