다른 모델에서 텍스트 필드를 미리로드하려고하는데 다음 코드가 작동하지 않습니다. 여기에 내 코드가 있습니다.
public function actionCreate($id)
{
$id1 = Yii::app()->user->id;
$model = new DoctorLists;
$prof = new Profile;
$prof = Profile::model()->findByPk($id)
$model->doctor_firstname = $prof->firstname;
$model->doctor_lastname = $prof->lastname;
$model->doctor_email = $prof->email;
$model->doctor_mobile_no = $prof->mobile_num;
$model->consult_no = $prof->alter_mobile_num;
if(isset($_POST['DoctorLists'])
{
$model->attributes=$_POST['DoctorLists'];
if($model->save())
{
$this->redirect(array('view','id'=>$model->doctor_id));
}
}
$this->render('create',array(
'model'=>$model,
));
}
쿼리를 간단하게 변경하여 작동하도록했고 여기에 작업 코드가 있습니다. 이제 다른 모델의 내용을 미리로드 할 수 있습니다.
public function actionCreate($id)
{
$id1 = Yii::app()->user->id;
$model = new DoctorLists;
$prof = new Profile;
$prof = Profile::model()->find('user_id=:user_id', array(':user_id'=>$id));
$model->doctor_firstname = $prof->firstname;
$model->doctor_lastname = $prof->lastname;
$model->doctor_email = $prof->email;
$model->doctor_mobile_no = $prof->mobile_num;
$model->consult_no = $prof->alter_mobile_num;
if(isset($_POST['DoctorLists'])
{
$model->attributes=$_POST['DoctorLists'];
if($model->save())
{
$this->redirect(array('view','id'=>$model->doctor_id));
}
}
$this->render('create',array(
'model'=>$model,
));
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다