【发布时间】:2014-02-27 05:36:01
【问题描述】:
我正在尝试从另一个模型预加载文本字段,我使用以下代码不起作用,这是我的代码。
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,
));
}
【问题讨论】:
-
很高兴您修复了它。与其提供覆盖问题的答案,不如将您的答案添加为答案。我们鼓励这样做,您也可以将其标记为已解决。你会在这里做吗?然后,您可以使用编辑工具将问题回滚到之前的状态。
标签: yii textfield preloading