/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = GeoRegion::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<legend><?php echo Yii::t("Bootstrap", "LIST.GeoRegion"); ?> </legend> <?php $assetsDir = Yii::app()->basePath; $labels = GeoRegion::model()->attributeLabels(); $this->widget('backendfilterWidget', array('listId' => 'geo-region-grid', 'model' => $model, 'columns' => array(array('country_id', 'select', 'listData' => CHtml::listData(GeoCountry::model()->findAll(array('order' => 'name_ru')), 'id', 'name_ru'), 'htmlOptions' => array('class' => 'span5'))))); echo '<a class="btn" href="/admin/georegion/georegion/create">Добавить</a>'; $this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'geo-region-grid', 'template' => "{items}\n{pager}", 'enableHistory' => true, 'dataProvider' => $model->with("country")->search(), 'filter' => null, 'bulkActions' => array('actionButtons' => $this->bulkRemoveButton(), 'checkBoxColumnConfig' => array('name' => 'id')), 'columns' => array(array('header' => $labels["id"], 'name' => "id"), array('header' => $labels["country_id"], 'name' => 'country_id', 'value' => '$data->country ? $data->country->name_ru : ""', 'filter' => CHtml::listData(GeoCountry::model()->findAll(array('order' => 'name_ru')), 'id', 'name_ru')), array('header' => $labels["name_ru"], 'name' => "name_ru"), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update} {delete}', 'buttons' => array('update' => array('label' => yii::t('Bootstrap', 'PHRASE.UPDATE'), 'url' => 'CHtml::normalizeUrl(array("update", "id" => $data->id))', 'options' => array()), 'delete' => array('label' => yii::t('Bootstrap', 'PHRASE.DELETE'), 'options' => array())), 'htmlOptions' => array('style' => 'white-space: nowrap')))));