在yii中保存下拉菜单状态"是"当页面重新加载时,如果选择了它?它默认为" No" ..谢谢!!
getAttributeLabel(' MULTI_PART_FORM')); ?>
<td class="type-text"><?php echo CHtml::dropDownList('MULTI_PART_PO','',array( 0=>'No',1=>'Yes'), array('onChange' => "$('#MULTI_PART_VIEW').show();")); ?></td>
</tr>
<tr id="MULTI_PART_VIEW" style="display:none">
<th><?php echo CHtml::encode($model->getAttributeLabel('MULTI_PART_VIEW')); ?></th>
<td><?php echo CHtml::activeTextField($model,'MULTI_PART_PO',array('size'=>120,'maxlength'=>64,'value'=>$model->MULTI_PART_PO)); ?></td>
<?php
答案 0 :(得分:1)
//VIEW CODE
echo CHtml::beginForm(Yii::app()->createUrl("{controllername}/save",array(/*'{controller parameter}'=>{parameter value},*/)),'post',array('id'=>'form_id'));
echo CHtml::dropDownList('MULTI_PART_PO',$saved_dropdown_value,array( 0=>'No',1=>'Yes'), array('onChange' => "$('#MULTI_PART_VIEW').show();"));
//dropDownList(string $name, string $select="the selected value", array $data, array $htmlOptions=array ( ))
echo CHtml::endForm();
//CONTROLLER CODE (add function Save to accessRules array)
public function actionSave(/*{controller parameter}*/)
{
$model=new {Modelname};
if(isset($_POST["MULTI_PART_PO"]))
{
$model->multi_part_po = $_POST["MULTI_PART_PO"];
$model->save();
}
$this->render('{Viewname}',array(
'saved_dropdown_value'=>$model->multi_part_po,
));
}