<?php use yii\helpers\Html; use yii\grid\GridView; /* @var $this yii\web\View */ /* @var $searchModel backend\models\FaktaSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Faktas'; $this->params['breadcrumbs'][] = $this->title; $wilayah = \yii\helpers\ArrayHelper::map(\common\models\Wilayah::find()->all(), 'id', 'nama'); $bulan = \yii\helpers\ArrayHelper::map(\common\models\Bulan::find()->all(), 'id', 'nama'); $variabel = \yii\helpers\ArrayHelper::map(\common\models\Variabel::find()->all(), 'id', 'nama'); $kategori = \yii\helpers\ArrayHelper::map(\common\models\Kategori::find()->all(), 'id', 'nama'); $sumberData = \yii\helpers\ArrayHelper::map(\common\models\SumberData::find()->all(), 'id', 'nama_cs'); ?> <div class="fakta-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Create Fakta', ['create'], ['class' => 'btn btn-success']); ?> </p>
public function actionChild() { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $out = []; if (isset($_POST['depdrop_parents'])) { $id = end($_POST['depdrop_parents']); $list = \common\models\Wilayah::find()->andWhere(['tipe' => $id])->asArray()->all(); $selected = null; if ($id != null && count($list) > 0) { $selected = ''; foreach ($list as $i => $account) { $out[] = ['id' => $account['id'], 'name' => $account['nama']]; if ($i == 0) { $selected = $account['id']; } } // Shows how you can preselect a value return ['output' => $out, 'selected' => $selected]; } } return ['output' => '', 'selected' => '']; }