Yii2 Lesson - 20 Dependent Drop Down Lists
Why Stack Overflow recommends it
Stack Overflow users link it when answering or citing how to build dependent dropdowns in Yii2, such as state and city or department and unit selects.
Recommended by 3 people across 3 different months, 2016 to 2017.
What it is
A 10-minute Yii2 PHP framework tutorial from a numbered lesson series showing how to build dependent drop down lists, where choosing a value in one field populates the next. The presenter walks through the view code and controller action using jQuery and ActiveForm.
What people said
Recommends JKLM · 2016-04 · Stack Overflow · on “Data is not populating in second level kartik depDrop in yii2. Gettin 0,1,2,3,4”
im in hurry now need to go out, [this video] watch this, this exactly what you need, if you still have issue post it i try to answer in evening
Recommends NoBody · 2016-06 · Stack Overflow · on “How to solve my code dependent dropdown without extentions”
I have done this before by following this tutorial [this video] . Below is my code. Hope this can help you. In view <div class='col-lg-4'> <?= $form->field($modelsBahagian, 'bahagian_id')->dropDownList( ArrayHelper::map(TblBahagian::find()->all(), 'bahagian_id', 'bahagian_nama'), [ 'prompt'=>'Pilih Bahagian', 'onchange'=>' $.post("index.php?r=tbl-moderator/lists&id='.'"+$(this).val(), function( data ) { $( "select#tblbhgnmod-unit_id" ).html( data ); });' ]); ?> </div> <div class='col-lg-4'> <?= $form->field($modelsBahagian, 'unit_id')->dropDownList( ArrayHelper::map(TblUnit::find()->all(),'unit_id','unit_nama'), ['prompt'=>'Sila Pilih unit'] ) ?> </div> In Controller public function actionLists($
Recommends Naeem Ali · 2016-12 · Stack Overflow · on “Yii2 : kartik Select2”
I have 2 select2 dropdownlist the second depends on data from the first one the first one code : <?= $form->field($model, 'patient_id')->widget(select2::className(),[ 'data'=> arrayhelper::map(patient::find()->all(),'patient_id','patient_name'), 'options'=>['placeholder'=>'select patient Name ... '], 'pluginOptions'=>[ 'allowClear'=>true ], ])?> the second one code : <?= $form->field($model, 'doctor_id')->widget(select2::className(),[ 'data'=> arrayhelper::map(doctors::find()->all(),'doctor_id','doctor_name'), 'options'=>['placeholder'=>'أختر اسم الطبيب '], 'pluginOptions'=>[ 'allowClear'=>true ], ])?> i know the sql code in the second one is : select doctor_name from doctors so i need it to
Cites gugoan · 2017-03 · Stack Overflow · on “Yii2 dependent DropdownList State and City”
I followed a [this video] tutorial to create a dependent DropdownList (State and City), and soon after loading, the Dropdownlist City displays all cities. I wish none were displayed, just when selecting a State. But I'm not sure how to do it and would like some help. Look how I did: VIEW: _search.php <?php $form = ActiveForm::begin([ 'action' => ['index'], 'method' => 'get', ]); ?> <?= $form->field($model,'state_id')->dropDownList( ArrayHelper::map(State::find()->all(), 'id', 'nome'), [ 'prompt'=>'Selecione', 'onchange'=>' $.get( "'.Url::toRoute('/city/lists').'", { id: $(this).val() } ) .done(function( data ) { $( "#'.Html::getInputId($model, 'city_id').'" ).html( data ); } );' ]); ?> <?= $form-