public function actionIndex() { $success = false; $model = new EmailForm(); if (!empty($_POST['EmailForm'])) { $model->setAttributes($_POST['EmailForm']); if ($model->validate()) { $success = true; // handle form here } } $this->render('index', array('model' => $model, 'success' => $success)); }