/**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['AdminEventModel'])) {
         $model->attributes = $_POST['AdminEventModel'];
         $model->updated_time = date('Y-m-d H:i:s');
         $model->updated_by = Yii::app()->user->id;
         $groupId = $_POST['AdminEventModel']['group_id'];
         $groupName = EventGroupModel::model()->findByPk(new MongoId($groupId))->name;
         $model->group_name = $groupName;
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->_id));
         }
     }
     $this->render('update', array('model' => $model));
 }
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
예제 #3
0
<?php

$this->pageLabel = Yii::t("admin", "Quản lý nhóm sự kiện");
$this->menu = array(array('label' => Yii::t("admin", "Thêm mới"), 'url' => array('create'), 'visible' => UserAccess::checkAccess('gamification-AdminEventGroupCreate')));
Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('admin-event-group-model-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
?>

<div class="search-form" style="display:none">
<?php 
$this->renderPartial('_search', array('model' => $model));
?>
</div><!-- search-form -->

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'admin-event-group-model-grid', 'dataProvider' => new EMongoDocumentDataProvider($model->search(), array('sort' => array('attributes' => array('_id', 'name', 'description')))), 'columns' => array(array('name' => 'name', 'header' => EventGroupModel::model()->getAttributeLabel("name"), 'value' => 'CHtml::link($data->name,array("update","id"=>$data->_id))', 'type' => 'raw'), array('name' => 'description', 'header' => EventGroupModel::model()->getAttributeLabel("description")), array('class' => 'CButtonColumn'))));