post - Yii postback value for dropdownlist -


like described in title, i' trying use dropdownlist post page. post receive in controller value selected empty. here dropdownlist

<?php echo chtml::dropdownlist('groupe',$groupe,  array("a"=>"a","b"=>"b","c"=>"c","d"=>"d","e"=>"e","f"=>"f","g"=>"g","h"=>"h"), array( 'prompt'=>'--choisir un groupe--', 'submit'=>ccontroller::createurl('classement'), //'data'=>array('groupe'=>'js:this.value'), ));  ?> 

and here controller

public function actionclassement($groupe="")     {echo $groupe;             if(isset($_post['groupe'])){echo $_post['groupe']."ici=".$groupe;                 $groupe = $_post['groupe'];             }echo 'test';             $model = team::model()->getclassementbygroupe($groupe);             $games = array();             $games = game::model()->getgamebygroupe($groupe);             //echo '<pre>test';echo print_r($model);echo '</pre>';             $this->render('classement',array(                     'model'=>$model,                     'groupe'=>$groupe,                     'games'=>$games,             ));     } 

thanks because don't find mistake :-s

you need wrap dropdown in form. worked. note $groupe gets assigned if there $_get variable. combo posting, need use $_post['groupe']

<form method="post" action="<?= $this->createurl('') ?>">   <?php   echo chtml::dropdownlist('groupe', $groupe, array(       "a" => "a",       "b" => "b",       "c" => "c",       "d" => "d",       "e" => "e",       "f" => "f",       "g" => "g",       "h" => "h"           ), array(       'prompt' => '--choisir un groupe--',       'submit' => ccontroller::createurl('classement'),           //'data'=>array('groupe'=>'js:this.value'),   ));   ?>   </form> 

i removed models testing controller.

public function actionclassement($groupe = "") {   echo $groupe;   if (isset($_post['groupe'])) {     echo $_post['groupe'] . "ici=" . $groupe;     $groupe = $_post['groupe'];   }echo 'test'; //   $model = team::model()->getclassementbygroupe($groupe); //   $games = array(); //   $games = game::model()->getgamebygroupe($groupe);   //echo '<pre>test';echo print_r($model);echo '</pre>';   $this->render('view', array(       'groupe' => $_post['groupe'],   )); } 

Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -