I am trying to use the DataTime widget using jquery . The display is working fine. But when i click he create button its not getting stored in database. It says the textbox is empty. The code i used is
<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name'=>'service_start_date',
'model'=>$model,
'attribute'=>'service_start_date',
'value'=>$model->service_start_date,
// additional javascript options for the date picker plugin
'options'=>array(
'showAnim'=>'fold',
'dateFormat'=>'yy-mm-dd'
),
'htmlOptions'=>array(
'style'=>'height:20px;',
),
)); ?>
// you must specify name or model/attribute
'name'=>'ModelName[service_start_date]',
forget model and attribute or use them ‘without the name’ as your name exposed above is wrong. It should work without it… never tried though, I use the above
// DO NOT INCLUDE NAME, your name is wrong must be ModelName[attributename]
'model'=>$model,
'attribute'=>'service_start_date',
Had this kind of problems before. I’ve used the yii debug toolbar extension http://www.yiiframework.com/extension/yiidebugtb/ to check what the form was actually posting because I was trying to assign to the attribute something that wasen’t posted.
With the toolbar you can click yii->request and you’ll see the posted array.
the time is stored as timestamp (converted in beforeValidate) in the database, which is fine. But for Update purposes I want to show the datetime (which was set before) in the format a custom format: Thought this would be working with the value-attribute, but with this code only the timestamp is shown.