public function actionContact() { if (isset($_POST['ajax']) && $_POST['ajax'] === 'contact-form') { $model = new ContactRecord(); echo CActiveForm::validate($model); Yii::app()->end(); } if (Yii::app()->request->isAjaxRequest) { $contact_record = new ContactRecord(); $id = $_POST['id']; $contact_record->user_id = $id; $contact_record->content = Yii::app()->user->name . ':' . $_POST['postContact']; $contact_record->time = date('y-m-d h:i'); if ($contact_record->save()) { $this->renderPartial('_info_contact', array('dataProvider' => $contact_record->search($id), 'id' => $id)); } } }