Pass multiple variables from view to controller in nice URL

Hi

I got url like this:

index.php?r=ukpostcode/index3/postcode/CH64/radius/6

I’m passing 2 variables to the controller it works ok

I’m trying to create now form which will contain 2 text fields (postcode, radius) and submit button to submit those values to the controller

but can’t to find any solution. I don’t want the Ajax it is important to have dynamic and simple clean url

public function actionIndex3($postcode,$radius)

{	





$model=new UkPostcode('search');


$postcode_found = UkPostcode::model()->find('postcode=:postcode',


array( 


  ':postcode'=>$postcode,


	));











$longitude = $postcode_found->longitude;


$latitude = $postcode_found->latitude;











$lng_min = $longitude - $radius / abs(cos(deg2rad($latitude)) * 69);


$lng_max = $longitude + $radius / abs(cos(deg2rad($latitude)) * 69);


$lat_min = $latitude - ($radius / 69);


$lat_max = $latitude + ($radius / 69);	


$criteria=new CDbCriteria(array(			


		'condition' => '(longitude BETWEEN '.$lng_min.' AND '.$lng_max.') AND (latitude BETWEEN '.$lat_min.' AND '.$lat_max.')',			


	));


	


	$dataProvider=new CActiveDataProvider('UkPostcode', array(


		'pagination'=>array('pageSize'=>Yii::app()->params['postsPerPage'],),


		'criteria'=>$criteria,


	));


	


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


	'dataProvider'=>$dataProvider,


	'model'=>$model,


	));		


}

If I good understand you would like to send data from the form by post request, then catch it inside the action, right? If yes, you should make you form able to send data via POST like below:


<?php

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

	'id' => 'someid',

	'enableClientValidation' => false,

	'clientOptions' => array(

	'validateOnSubmit' => true,

	),

));

?>


<?php echo $form->labelEx($model,'field'); ?>

<?php echo $form->textField($model,'field'); ?>

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

          

<?php echo CHtml::submitButton(Yii::t('app', 'Send')); ?>            

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

and catch it like below:


if(Yii::app()->request->isPostRequest)

{

 // do something with $_POST here

}

Maybe this can help you a little:

http://www.yiiframew…-an-index-page/

thanks