Jump to content
Larry Ullman's Book Forums

babakitien

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by babakitien

  1. 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

×
×
  • Create New...