Jump to content
Larry Ullman's Book Forums

Get The Current Value Of Dropdownlist Into A View


babakitien
 Share

Recommended Posts

Hi there,

 

As a YII2 beginner, i have a very easy question, and i was really surprised to not find the answer by myself on the internet but i have to say that after some research i didn't find anything. Question is:

 

How to get the current value of a dropDownList into a view? (to fill a grid depending of the value of the dropDownList)

 

So here is my code:

<?= $form->field($model, 'spe')->dropDownList(
                 ArrayHelper::map(Specialites::find()->all(), 'id_spe', 'lib_spe'),
                 [
                  'prompt'=>'Choose a spe',
                 ])->label('Spécialité'); ?>
     
<?php $dataProvider = new ActiveDataProvider([
  'query' => Parcours::find()->where(['fk_parcours_spe'=>'/*NEED ID_SPE HERE*/']),
        'pagination' => [
            'pageSize' => 20,
        ],
    ]);
    echo GridView::widget([
        'dataProvider' => $dataProvider,
    ]); ?>

So as you can see: i need to get the id_spe of the dropdownlist right on top of my grid, it seems so easy (like spe.val() in JS) but i can't manage to find how to do so =P

 

Could you help me with this? thanks before.

 

babakitien

Link to comment
Share on other sites

 Share

×
×
  • Create New...