Hello all,
I am new to yii and I was trying to create a dropdown list with an ‘other’ option at last and when i click on it, a popup occurs of a text field and then i enter a value there and it gets added to the list,so that it shows the updated list.
How can i do this?
This is my form
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use yii\web\JsExpression;
/* @var $this yii\web\View /
/ @var $model app\models\Department /
/ @var $form yii\widgets\ActiveForm */
?>
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'deptname')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'deptlocation')->dropDownList(
ArrayHelper::map(\app\models\Location::find()->all(), 'loc', 'loc'), // Flat array ('id'=>'label')
['prompt' => 'Select',])
?>
<div class="form-group">
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
Thank you