Get A Value From A Submitted Form

Hi, I’m new to YII Framework. What I’m trying to implement is Get a value of a dropdown function for another action to process a calculation.

First there is a form that has the dropdown,

<div class="form">

  <?php echo CHtml::beginForm('', 'POST'); ?>

    <?php echo CHtml::errorSummary($model); ?>

      <div class="row">

        <?php echo CHtml::activeLabel($model,'employeeID'); ?>

		<?php echo CHtml::activeDropDownList($model,'employeeID', CHtml::listData(Employee::model()->findAll(), 'employeeID','employeeID'), array('empty'=>'---Select one---')); ?>     


	 <div class="row submit">

       <?php echo CHtml::button('Submit', array('submit'=> array('salary/calsal'))); //  ?>	


      <?php echo CHtml::endForm(); ?>

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

Then in the other form I tried to get that selected value

	public function actionCal()


		$model=new Salary;






	public function actionCalsal()



		echo $id;


this is the salary controller. first action sends $model to the above form. and second action tries to get the selected value from that form. but I always end up with getting this error. Undefined index: $model

Can someone please help me to do it properly. I have to implement it as a part of my Uni stuff. Thanks in advance! :)

should be $_POST[‘Salary’][‘employeeID’] I suppose.

When using $_POST, you are getting the values from a form using the “name” attribute. So unless you have an input that has a name “$model”, you won’t get any value from $_POST["$model"]. ORey’s answer might be correct, considering how Yii automatically creates a “name” attribute for every form input.

Thanks a lot ORey! It worked! :D And thanks macinville for confirming it. You guys are the best!