public function actionAddDoctor() { $this->authenUser(); $this->authenManagement(); $formAddDoctor = new formAddDoctor(); $addDoctor = new Doctor(); $systemCities = SystemCity::model()->findAll(); $systemCitiesData = $this->generateSystemCities($systemCities); if (isset($_POST['formAddDoctor'])) { $addDoctor->attributes = $_POST['formAddDoctor']; $addDoctor->regDate(); print_r($_POST['formAddDoctor']); $addDoctor->save(); if ($addDoctor->did != NULL) { $doctorAddress = $_POST['formAddDoctor']['address']; $doctorCity = $_POST['formAddDoctor']['city']; if ($doctorAddress != '' || $doctorCity != '') { $addDoctorAddress = new DoctortAddress(); $addDoctorAddress->doctor_did = $addDoctor->did; if ($doctorAddress != '') { $addDoctorAddress->address = $doctorAddress; } if ($doctorCity != '') { $addDoctorAddress->system_city_id = $doctorCity; } $addDoctorAddress->save(); } } Yii::app()->end(); } $formAddDoctor->generatePassword(); $this->render('addDoctor', array('formAddDoctor' => $formAddDoctor, 'systemCitiesData' => $systemCitiesData)); }