/** * Creates a new District model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { if (DistrictAccess::allowCreate() == FALSE) { throw DistrictAccess::exception('create'); } $model = new District(); try { if ($model->load($_POST) && $model->save()) { return $this->redirect(Url::previous()); } elseif (!\Yii::$app->request->isPost) { $model->load($_GET); } } catch (\Exception $e) { $msg = isset($e->errorInfo[2]) ? $e->errorInfo[2] : $e->getMessage(); $model->addError('_exception', $msg); } return $this->render('create', ['model' => $model]); }
<?php // echo $this->render('_search', ['model' =>$searchModel]); ?> <div class="clearfix"> <p class="pull-left"> <?php echo DistrictAccess::button('create'); ?> </p> <div class="pull-right"> <?php echo DistrictAccess::button('index'); ?> </div> </div> <?php \yii\widgets\Pjax::begin(['id' => 'pjax-main', 'enableReplaceState' => false, 'linkSelector' => '#pjax-main ul.pagination a, th a', 'clientOptions' => ['pjax:success' => 'function(){alert("yo")}']]); ?> <div class="panel panel-default"> <div class="panel-heading"> <h2> <i><?php echo $this->title;
<?php // echo $this->render('_search', ['model' =>$searchModel]); ?> <div class="clearfix"> <p class="pull-left"> <?php echo DistrictAccess::button('create'); ?> </p> <div class="pull-right"> <?php echo DistrictAccess::button('deleted'); ?> </div> </div> <?php \yii\widgets\Pjax::begin(['id' => 'pjax-main', 'enableReplaceState' => false, 'linkSelector' => '#pjax-main ul.pagination a, th a', 'clientOptions' => ['pjax:success' => 'function(){alert("yo")}']]); ?> <div class="panel panel-default"> <div class="panel-heading"> <h2> <i><?php echo $this->title;
<?php $this->beginBlock('Districts'); ?> <div style='position: relative'> <div style='position:absolute; right: 0px; top: 0px;'> <?php echo DistrictAccess::button('index', ['label' => 'All Districts', 'buttonOptions' => ['class' => 'btn btn-success btn-xs']]); ?> <?php echo DistrictAccess::button('create', ['label' => 'New District', 'urlOptions' => ['DistrictForm' => ['country_id' => $model->country_id, 'province_id' => $model->province_id, 'city_id' => $model->id]], 'buttonOptions' => ['class' => 'btn btn-success btn-xs']]); ?> </div> </div> <?php Pjax::begin(['id' => 'pjax-Districts', 'enableReplaceState' => false, 'linkSelector' => '#pjax-Districts ul.pagination a, th a', 'clientOptions' => ['pjax:success' => 'function(){alert("yo")}']]); ?> <?php echo '<div class="table-responsive">' . \yii\grid\GridView::widget(['layout' => '{summary}{pager}<br/>{items}{pager}', 'dataProvider' => new \yii\data\ActiveDataProvider(['query' => $model->getDistricts(), 'pagination' => ['pageSize' => 50, 'pageParam' => 'page-districts']]), 'pager' => ['class' => yii\widgets\LinkPager::className(), 'firstPageLabel' => 'First', 'lastPageLabel' => 'Last'], 'columns' => [['class' => 'yii\\grid\\SerialColumn', "options" => ["width" => "50px"]], 'number', ["attribute" => "name", "format" => "raw", "options" => [], "value" => function ($model) { return $model->linkTo; }]]]) . '</div>'; ?> <?php Pjax::end(); ?>