[英]yii dropDownList populated data dynamically with Javascript posting null values
How do I retrieve the value which is populating data dynamically with Javascript in yii
framework? 如何在
yii
框架中检索使用Javascript动态填充数据的值? When I post the data it's inserting the database as null
当我发布数据时,它会将数据库插入为
null
in view 鉴于
<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>
in controller 在控制器中
$model = new EmailForm;
if (isset($_POST['EmailForm'])) {
$model->attributes = $_POST['EmailForm'];
echo $model->otherdate; //value null
}
Have you added 'otherdate', 'othermonth' and 'otheryear' to the rules of your model? 您是否在模型规则中添加了“其他日期”,“其他月份”和“其他年份”?
public function rules()
{
return array(
array('otherdate, othermonth, otheryear', 'safe'),
);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.