Updating Variables Using Cactiveform Search

I would like to temporarily update the value of the variable "tempSeats" based on the input from a search form. The search form updates a CGridView which I use to generate links based on flight selected and customer id. I would also like it to add the number of "tempSeats" from search form to the generated url.

So far I have been able to pass the customer id and flight id without a problem. I just can’t seem to get the tempSeats to update when the search form is submitted. It always has 0 as the value being passed.

Any help would be greatly appreciated.

Here is my search form:


<?php $form=$this->beginWidget('CActiveForm', array(

    	'action'=>Yii::app()->createUrl($this->route),

    	'method'=>'get',

    )); ?>

    	<span style="font-size:18px;font-weight:bold;">Route: </span>

    	<div class="row">

                  <?php echo CHtml::dropDownList(

         'departLocation',// for "name" attribute of <select> html tag,

                    // this also becomes the "id" attribute, incase you don't specify

                    // it explicitly in the htmlOptions array

         '', // the option element that is to be selected by default

         CHtml::listData( // listData helps in generating the data for <option> tags

            Airport::model()->findAll(), // a list of model objects. This parameter

                  // can also be an array of associative arrays

                  // (e.g. results of CDbCommand::queryAll).

            'airportName', // the "value" attribute of the <option> tags, 

                  // here will be populated with id column values from program table 

            'airportName' // the display text of the <option> tag,

                  // here will be populated with program_name column values from table

         ),

         array('empty'=>'From') // the htmlOptions array, whose values will be

                  // generated as html attributes of <select> and <option> tags

    );?>

    		<?php echo CHtml::dropDownList(

         'arrivalLocation',

         'empty',

         CHtml::listData(

            Airport::model()->findAll(),

            'airportName',

            'airportName'

         ),

         array('empty'=>'To')

    );?>

    	</div>

    	<hr>

    	<span style="font-size:18px;font-weight:bold;">Dates:</span>

    	<div class="row">

    		Departing:

    		<?php

    $this->widget('zii.widgets.jui.CJuiDatePicker', array(

        'model' => Flights::model(),

        'attribute' => 'departDay', 

        'value'=>Flights::model()->departDay,

        'options' => array(

        	'numberOfMonths'=>1,

            'showButtonPanel'=>true,

            'dateFormat' => 'yy-mm-dd',),

    	'htmlOptions' => array(

    		'class' => 'date',

    		 'value' => date("Y-m-d")),

    ));

    ?>

    <?php echo $form->error($model,'date_from'); ?>

    	</div>

    	<hr>

    	<span style="font-size:18px;font-weight:bold;">Travelers:</span>

    	<div class="row">

    		

                  <?php echo CHtml::activeDropDownList($model,'tempSeats',array('1' => '1 Adult', '2' => '2 Adults', '3' => '3 Adults', '4' => '4 Adults', '5' => '5 Adults', '6' => '6 Adults', '7' => '7 Adults', '8' => '8 Adults', '9' => '9 Adults', '10' => '10 Adults', '11' => '11 Adults', '12' => '12 Adults', '13' => '13 Adults', '14' => '14 Adults', '15' => '15 Adults', '16' => '16 Adults', '17' => '17 Adults', '18' => '18 Adults', '19' => '19 Adults', '20' => '20 Adults',)

                  );?>

    

    

            

    		<?php echo CHtml::dropDownList('infant-list', $select, 

                  array('0' => '0 Lap Infants (under 2)','1' => '1 Lap Infant',)

                  ); ?>

                  <?php echo CHtml::dropDownList(

         'dogSeats',

         'empty',

         CHtml::listData(

            Flights::model()->findAll(),

            'allowDogs',

            'allowDogs'

         ),

         array('empty'=>'0 Dogs')

    );?>

    	</div>

    

    	<div class="row buttons">

    		<?php echo CHtml::submitButton('Submit'); ?>

    	</div>

    	</div>

    

    <?php $this->endWidget(); ?>

Here is the view in which the search form is rendered:


    <?php $this->renderPartial('_searchFlights',array(

    'model'=>$model,

    )); ?>


    <?php

    

    Yii::app()->clientScript->registerScript('searchFlights', "

    $('.search-button').click(function(){

    $('.search-form').toggle();

    return false;

    });

    $('.search-form form').submit(function(){

    $.fn.yiiGridView.update('my-list', {

    data: $(this).serialize()

    });

    

    return false;

    });

    ");

    

    ?>

    

    

    

    <?php $this->widget('zii.widgets.grid.CGridView', array(

    	'id'=>'my-list',

    	'dataProvider'=>$model->searchFlights(),

    	'filter'=>$model,

    	'columns'=>array(

    		'departTime',

    		'departLocation',

    		'departDay',

    		'arrivalTime',

    		'arrivalLocation',

    		'price',

    		'totalSeats',

    		array(

    			'header'=>'Seats',

    			'value'=>'0',

    			'id'=>'adultSeats',

    			),

    		/*

    		

    		'allowDogs',

    		*/

    		array(

        'class'=>'CButtonColumn',

        'template'=>'{book}',

        'buttons'=>array

        (

            'book' => array

            (

                'label'=>'Book Now',

                //'url'=>'CHtml::encode($data->flightID)',

                //'url'=>'$this->grid->controller->createUrl("/bookings/createBooking", array("flightID"=>$data->flightID))',

                'url'=>'$this->grid->controller->createUrl("/bookings/createBooking/flightID/$data->flightID/tempSeats/$data->tempSeats")',

            ),

        ),

    ),

    	),

    )); ?>

Here is my function for the search in my Flights model:


 public function searchFlights()

    	{

    		// Warning: Please modify the following code to remove attributes that

    		// should not be searched.

    

    		$criteria=new CDbCriteria;

    

    		$criteria->compare('flightID',$this->flightID);

    		$criteria->compare('flightName',$this->flightName,true);

    		$criteria->compare('departDay',$this->departDay,true);

    		$criteria->compare('departTime',$this->departTime,true);

    		$criteria->compare('departLocation',$this->departLocation,true);

    		$criteria->compare('arrivalDay',$this->arrivalDay,true);

    		$criteria->compare('arrivalTime',$this->arrivalTime,true);

    		$criteria->compare('arrivalLocation',$this->arrivalLocation,true);

    		$criteria->compare('totalSeats',$this->totalSeats);

    		$criteria->compare('price',$this->price,true);

    		$criteria->compare('allowDogs',$this->allowDogs);

    		$criteria->compare('infantSeats',$this->infantSeats);

    		$criteria->compare('dogSeats',$this->dogSeats);

    		$criteria->compare('tempSeats',$this->totalSeats);

and here is my actionIndex from the Flight Controller:


/**

    	 * Lists all models.

    	 */

    	public function actionIndex()

    	{

    		$model = new Flights('search');

    $model->unsetAttributes(); // clear any default values

    if (isset($_GET['Flights']))

    $model->attributes = $_GET['Flights'];

    

    $dataProvider=new CActiveDataProvider('Flights');

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

    'model' => $model,

    'dataProvider'=>$dataProvider,

    ));

    	}