Button is not calling Controller Aktion

Hello, i created a new button on my index.php wich should call a simple Controller aktion.

mit index.php looks like this :




<?php

$this->pageTitle=Yii::app()->name;

?>


<h1>Please insert a valid E-Mail adress:<i></h1>


<div class="form">

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

	'id'=>'search-form',

)); ?> 


	<div class="row">

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

	</div>

	

	<div class="row buttons">

		<?php echo CHtml::submitButton('Submit',array('site/search','id'=>$model->email)); ?>

	</div>


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

</div><!-- form -->

The SearchForm.php:


<?php

class SearchForm extends CFormModel

{

	public $email;


	public function rules()	{

		return array(

			array('email', 'required'),

		);}


	public function search(){

	return true;

	}

}

and in my SiteController.php

the aktion i whant to call:




...

  public function actionSearch($id) {

		 $model=new SearchForm;

		 

		if (isset($_POST['id']))

		 {

		  	 $var = $_GET['email'];

			echo "test";

		  }

		 // display the search form

		 $this->render('result',array('model'=>$model));

	 }

...

I dont get it why the Button is not calling/using the actionSearch function in my Controller.

The goal is that result.php is renderd with the correct email within the SearchForm.

Thanks in advance for any help

What is happening when you do click the submit button? In your actionSearch, try this




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

    $model->attributes = $_POST['SearchForm'];

}



This is the way you use Yii to populate your model fields with posted data.

If i press the button it calls the actionIndex() funktion for some reason.


    public function actionIndex()

	{

		$model = new SearchForm;

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

		    $model->attributes = $_POST['SearchForm'];

			if(strlen($model->email)>=5){

			$this->render('result',array('model'=>$model,));

			break;}

		}

		$this->render('index',array('model'=>$model,));

	}

but your code was usefull for now i will do all the stuff in the actionIndex() funktion.

thanks

Did you look at the source code to make sure the link is being created correctly?