/**
  * Creates a new Postcode model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (PostcodeAccess::allowCreate() == FALSE) {
         throw PostcodeAccess::exception('create');
     }
     $model = new PostcodeForm();
     try {
         if ($model->load($_POST) && $model->save()) {
             return $this->redirect(ReturnUrl::getUrl(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]);
 }
예제 #2
0
	<?php 
//     echo $this->render('_search', ['model' =>$searchModel]);
?>

    <div class="clearfix">

        <p class="pull-left">
			<?php 
echo PostcodeAccess::button('create');
?>
		</p>

        <div class="pull-right">
			<?php 
echo PostcodeAccess::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 'Postcodes';
예제 #3
0
?>


			<?php 
$this->beginBlock('Postcodes');
?>

			<div style='position: relative'>
				<div style='position:absolute; right: 0px; top: 0px;'>

					<?php 
echo PostcodeAccess::button('index', ['label' => 'All Postcodes', 'buttonOptions' => ['class' => 'btn btn-success btn-xs']]);
?>

					<?php 
echo PostcodeAccess::button('create', ['label' => 'New Postcode', 'urlOptions' => ['PostcodeForm' => ['country_id' => $model->country_id, 'province_id' => $model->id]], 'buttonOptions' => ['class' => 'btn btn-success btn-xs']]);
?>

				</div>
			</div>

			<?php 
Pjax::begin(['id' => 'pjax-Postcodes', 'enableReplaceState' => false, 'linkSelector' => '#pjax-Postcodes 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->getPostcodes(), 'pagination' => ['pageSize' => 50, 'pageParam' => 'page-postcodes']]), 'pager' => ['class' => yii\widgets\LinkPager::className(), 'firstPageLabel' => 'First', 'lastPageLabel' => 'Last'], 'columns' => [['class' => 'yii\\grid\\SerialColumn', "options" => ["width" => "50px"]], ["attribute" => "postcode", "format" => "raw", "options" => [], "value" => function ($model) {
    return $model->linkTo;
}], ['attribute' => 'city_id', "format" => "raw", "options" => [], 'value' => function ($model) {
    return $model->city ? $model->city->linkTo : '<span class="label label-warning">?</span>';
}], ['attribute' => 'district_id', "format" => "raw", "options" => [], 'value' => function ($model) {
    return $model->district ? $model->district->linkTo : '<span class="label label-warning">?</span>';
예제 #4
0
	<?php 
//     echo $this->render('_search', ['model' =>$searchModel]);
?>

    <div class="clearfix">

        <p class="pull-left">
			<?php 
echo PostcodeAccess::button('create');
?>
		</p>

        <div class="pull-right">
			<?php 
echo PostcodeAccess::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 'Postcodes';