public function actionReply() { $model = new Reply(); // uncomment the following code to enable ajax-based validation /* if(isset($_POST['ajax']) && $_POST['ajax']==='reply-reply-form') { echo CActiveForm::validate($model); Yii::app()->end(); } */ $insert = new Compose(); if (isset($_POST['Reply'])) { $subject = Yii::app()->user->getState('subject'); $email = Yii::app()->user->getState('email'); $body = $_POST['Reply']['body']; $date = DATE('Y:M:D'); $insert->subject = $subject; $insert->email = $email; $insert->body = $_POST['Reply']['body']; $insert->date = DATE("Y-m-d H+6:i:s"); $insert->save(); mail($email, $subject, $date, $body); $this->render('mails'); $model->attributes = $_POST['Reply']; exit; if ($model->validate()) { // form inputs are valid, do something here return; } } $this->render('reply', array('model' => $model)); }