public function actionEditDob() {
$model = new ChangeDob;
if(isset($_POST["ChangeDob"])){
$model->attributes=$_POST["ChangeDob"];
if($model->validate())
$this->redirect(Yii::app()->user->returnUrl);
}
// displays the login form
$this->render('profile_edit');
$this->render('profile_edit',array('model'=>$model));
return $model;
}
Mode :ChangeDob
public function rules()
{
return array(
array('dob', 'required'),
);
}
Is it giving you the same error or a different one after you remove those two lines? The original error really doesn’t make much sense if you’ve followed the suggestions above.
The whole point of passing the model into the view from the controller is to allow the form fields to persist and to show any errors. I don’t recommend declaring a new model in the view.
It works, but this is nor the way to solve your problem and it will not work at all for the update action… you need to create the model in the controller and pass that variable to the view.