public function actionIndex() { $model = Counter::model()->find(); if (empty($model)) { $model = new Counter(); } if (!empty($_POST['Counter'])) { $model->attributes = $_POST['Counter']; $model->year = $_POST['Counter']['year']; if ($model->save()) { Yii::app()->user->setFlash('success', translate('Cập nhật thành công.')); $this->redirect(PIUrl::createUrl('/admin/counter')); } } $this->render('index', array('model' => $model)); }