babakitien Posted June 26, 2015 Share Posted June 26, 2015 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 More sharing options...
laurent vignaux Posted June 28, 2015 Share Posted June 28, 2015 hello Babakitien, perhaps your internet's solution http://www.yiiframework.com/forum/index.php/topic/48375-creating-a-drop-down-list/ or http://stackoverflow.com/questions/16036927/get-selected-value-from-chtmldropdownlist best regards Link to comment Share on other sites More sharing options...
babakitien Posted July 1, 2015 Author Share Posted July 1, 2015 Laurent, le lien stack overflow m'a l'air bien Merci pour le coup de main! Link to comment Share on other sites More sharing options...
laurent vignaux Posted July 1, 2015 Share Posted July 1, 2015 De rien babakitien, J'espère que cela résoudra ton problème. Moi, j'ai un interrogation avec l'exemple du CMS ch22 version Yii1. J'ai l'impression qu'il manque des fichiers et dossiers As tu teste cet exemple ? cordialement Link to comment Share on other sites More sharing options...
Recommended Posts