1
如何檢索使用Javascript在yii
框架中動態填充數據的值?當我發佈它插入數據庫null
yii dropDownList使用Javascript發佈空值動態填充數據
鑑於
<ul class="birthday">
<li><?php echo $form->dropDownList($model, 'otherdate',array());?></li>
<li><?php echo $form->dropDownList($model, 'othermonth',array());?></li>
<li><?php echo $form->dropDownList($model, 'otheryear',array());?></li>
<script type="text/javascript">
date_populate("EmailForm_otherdate", "EmailForm_othermonth", "EmailForm_otheryear");
</script>
</ul>
在控制器中的數據
$model = new EmailForm;
if (isset($_POST['EmailForm'])) {
$model->attributes = $_POST['EmailForm'];
echo $model->otherdate; //value null
}
你在哪裏發佈數據到數據庫?你能提供那個代碼嗎? – squarephoenix 2012-04-13 19:09:45
編輯了代碼。 – memo 2012-04-13 19:15:05
查看這裏的第一個函數:http://www.yiiframework.com/doc/guide/1.1/en/form.table,你可能必須使用getItemsToUpdate();然後循環$模型來分配屬性1,一次修復 – squarephoenix 2012-04-13 19:47:57