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>
<div class="row submit">
<?php echo CHtml::button('Submit', array('submit'=> array('salary/calsal'))); // ?>
</div>
<?php echo CHtml::endForm(); ?>
</div><!-- form -->
Then in the other form I tried to get that selected value
public function actionCal()
{
$model=new Salary;
$this->render('calc',array(
'model'=>$model,
));
}
public function actionCalsal()
{
$id=$_POST['$model'];
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!