Drowpdownlist Submit

Hi All

In my app I had form and visitors can select any city to go to another page related to selected value .

So I created my code , but the problem data not sent .

Data is city id , I tested it in tamper data and no data sent , how to fix that and send data in get method

Model:




    	public function events_by_city(){

    	


   	return CHtml::listData(Events::model()->findAll("start >=now()  and active=1"),'city','city0.ecity');

    	

	}



Controller :




 //////// start upcoming related to city 

 public function actionUpcomingcity(){

	

	if(isset($_GET['city'])){  

   	$city=intval($_GET['city']);

	

	

   

   	$courses=Courses::model()->findAll(" course_id in (select course_id from ict_events where start >=now() and city=$city and active=1 ) ",array('distinct'=>true,

))  ;  

    	

    	$this->pageTitle=" Events";

    	$this->layout='rsidebar';

    	

   		$this->render('upcoming_by_city',array(

			'courses'=>$courses

		));

	

  }

  else{

	

	echo " No number   ";

  }

 

 }

 




View :




<?php

   

   CHtml::form();

   

  $model= new Events;

  echo  chtml::activeDropDownList($model,'city',$model->events_by_city(),array('prompt'=>'استعراض الأحداث التدريبية ',"submit"=>array("site/upcomingcity",'city'=>$model->city)




  )




); 




CHtml::endForm();


?>



Thanks in advance

Dear My Brother




echo CHtml::beginForm();

 //if you are using activeDropDown List ,the name resolve to ModelName['attributeName'], so simply use CHtml::dropDownList..,

echo CHtml::dropDownList('city','',$model->events_by_city(),array('prompt'=>'استعراض الأحداث التدريبية ',"submit"=>array("site/upcomingcity")


  )


); 




echo CHtml::endForm();




Then in controller.




public function actionUpcomingcity(){

        //submit option always submit the form in POST...

        if(isset($_POST['city'])){  

        $city=intval($_POST['city']);


//REST OF THE LOGIC....



Regards

Thanks my broblem still city not send also via post method and i used " Tamper data " tool to capture http requests and result

no data sent .

Ok

Let us consider an example.

In a controller view, I am making a dropDown in the following way.




echo CHtml::beginForm();

echo CHtml::dropDownList('fruit','',array('apple'=>'apple','orange'=>"orange",'banana'=>'banana'),array(

    'submit'=>array('trial/collect'),

    'prompt'=>'select'

));

echo CHtml::endForm();



TrialController.php




        public function actionCollect()

	{

		print_r($_POST);

	}



This is the screen shot from firebug in my localhost, when I choose banana in dropdown.

3882

fruit.png

Regards.

Thanks my bro for ur explain and example , everything work :D

Kill two birds in one stone!

I learned something today =)