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

What's the best way to create a style reset for only a portion of the DOM?

css css-reset css-specificity

I'm trying to create a css reset that targets only my control. So the HTML will look something like this:

How to find unused attributes/methods in Visual C++ 2008

c++ visual-studio visual-studio-2008 visual-c++ static-analysis

Is there a way to identify unused attributes/methods in Visual C++ 2008 Professional? If it's not possible by default, recommendations of 3rd-party tools are also much appreciated.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.