I have dropdown that is binding in modal. using the below code:
public function getYears()
{
for ($i=date('Y');$i>=2012;$i--)
{
$years["{$i}"]="{$i}";
}
return $years;
}
and my view is :
<div class="row">
<?php echo $form->labelEx($model,'year'); ?>
<?php echo CHtml::activedropDownList($model,'years',$model->getYears(),array('class'=>'myClass')); ?>
<?php echo $form->error($model,'year'); ?>
<?php echo $form->labelEx($model,'name'); ?>
<?php
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'name'=>'name',
'source'=>$this->createUrl('reports/autocompleteTest'),
'options'=>array(
'delay'=>300,
'minLength'=>2,
'showAnim'=>'fold',
),
));
?>
<?php echo $form->error($model,'name'); ?>
<?php echo $form->labelEx($model,'Status'); ?>
<?php echo $form->dropDownList($model,'is_active',array("1"=>"Active","0"=>"InActive")); ?>
<?php echo $form->error($model,'Status'); ?>
</div>
<div class="summary_btn buttons"> <?php echo CHtml::submitButton('Search'); ?> </div>
<?php $this->endWidget(); ?>
</div>
</div>
Now when i click on a button(Search), my page is making post back. and it rebinds the dropdown list. i dont know how can i retain the selected value in dropdown after the button click. I am new to yii. Please help me.
When i click on a button (Search).