/** * Lists all Concert models. * @return mixed */ public function actionIndex() { Country::getAll(); $dataProvider = new ActiveDataProvider(['query' => Concert::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }
use kartik\select2\Select2; use yii\helpers\ArrayHelper; use app\models\Country; /* @var $this yii\web\View */ /* @var $model app\models\Concert */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="concert-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'country')->widget(Select2::classname(), ['data' => ArrayHelper::map(Country::getAll(), 'code', 'name'), 'options' => ['placeholder' => 'Select a country ...']]); ?> <?php echo $form->field($model, 'city')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'place')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'date')->widget(DatePicker::className(), ['options' => ['class' => 'form-control', 'style' => 'width:200px'], 'dateFormat' => 'yyyy-MM-dd']); ?> <?php