/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { if (Yii::app()->getRequest()->getIsAjaxRequest() and $_GET['ajax'] == 1) { $response = array(); $model = new AAddress(); $model->city = 'Bengaluru'; //get localities list -start $modelArr = ABangaloreLocalities::model()->findAll(array('condition' => 'is_deleted = "no"', 'order' => 'locality_name ASC')); $locality_array = array(); foreach ($modelArr as $singleModel) { $locality_array[$singleModel->id] = $singleModel->locality_name; } $locality_array[""] = "Select any area"; //get localities list -stop // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['AAddress'])) { $model->attributes = $_POST['AAddress']; $currDateTime = new DateTime(); $model->creation_time = $currDateTime->format('Y-m-d H:i:s'); $model->link = AppCommon::getUserDetailsId(); $model->link_table = "user_details"; if ($model->save()) { //$this->redirect(array('view','id'=>$model->id)); //sending row html code with checked radio button $response["isRecordSaved"] = 1; $id_temp = $model->id; $Loc_name_temp = $model->address2bangaloreLocalities->locality_name; $address_temp = $model->getAddressString(); $response["html"] = '<tr><td>' . CHtml::activeRadioButton(new CheckoutFirstStageForm(), 'address', array('value' => $id_temp, 'required' => true, 'checked' => true, 'data-locality_name' => $Loc_name_temp, 'uncheckValue' => NULL)) . '</td><td>' . $address_temp . '</td><td>' . $Loc_name_temp . '</td><tr>'; $response["locality"] = $Loc_name_temp; echo CJSON::encode($response); Yii::app()->end(); } } $response["html"] = $this->renderPartial('create', array('model' => $model, 'locality_array' => $locality_array), true, false); $response["isRecordSaved"] = 0; echo CJSON::encode($response); Yii::app()->end(); } }