public function actionRegisterProfile() { $model = new RegisteredProfiles('login'); $sr_model = new ServicesRequested(); // uncomment the following code to enable ajax-based validation /* if(isset($_POST['ajax']) && $_POST['ajax']==='registered-profiles-registerProfile-form') { echo CActiveForm::validate(array($model, $sr_model)); Yii::app()->end(); } */ if (isset($_POST['RegisteredProfiles'])) { $model->attributes = $_POST['RegisteredProfiles']; if ($model->validate()) { if ($model->save()) { $serviceId = $_POST['ServicesRequested']['serviceId']; $sr_model->attributes = array('profileId' => $model->id, 'serviceId' => $serviceId, 'confirmed' => 0); if ($sr_model->save()) { $this->render('requestSubmitted', array('model' => $model)); return; } } } } $this->render('index', array('model' => $model, 'sr_model' => $sr_model)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return RegisteredProfiles the loaded model * @throws CHttpException */ public function loadModel($id) { $model = RegisteredProfiles::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }