How do I retrieve the value which is populating data dynamically with Javascript in yii framework? When I post the data it’s inserting the database as 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?