如何在yii
框架中检索使用Javascript动态填充数据的值?当我发布数据时,它将数据库插入null
在视图中
<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
}
答案 0 :(得分:0)
您是否在模型规则中添加了'otherdate','othermonth'和'otheryear'?
public function rules()
{
return array(
array('otherdate, othermonth, otheryear', 'safe'),
);
}