yii dropDownList使用Javascript发布空值动态填充数据

时间:2012-04-13 19:05:32

标签: php javascript jquery forms yii

如何在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
}

1 个答案:

答案 0 :(得分:0)

您是否在模型规则中添加了'otherdate','othermonth'和'otheryear'?

public function rules() 
{
    return array(
        array('otherdate, othermonth, otheryear', 'safe'),
    );
}