Jump to content
Larry Ullman's Book Forums

Get The Current Value Of Dropdownlist Into A View


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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...