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? 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
}

Answers


Have you added 'otherdate', 'othermonth' and 'otheryear' to the rules of your model?

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

Need Your Help

How to creat a event Trigger when download is finished

java android eventtrigger

am writing a downloadManager and i need a hint. there i could create an event an fire it when ever i wanted. but i cant seem to find how to do that in java. what i want to do is i want to create an...

Evolutionary Algorithms: Optimal Repopulation Breakdowns

computer-science artificial-intelligence genetic-algorithm genetic-programming evolutionary-algorithm

It's really all in the title, but here's a breakdown for anyone who is interested in Evolutionary Algorithms: