DateTime Picker with database

Hi all,

 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(





                            // additional javascript options for the date picker plugin








                        ));  ?> 

The column name is service_start_date.

When you provide the ‘model’ and ‘attribute’ parameters, it isn’t necessary to set the ‘name’ parameter.

Can you try leaving it out?

Hi krisd,

I just tried by removing the ‘name’ parameter. It still says “Service Start Date cannot be blank”.

Can you post you controller code please?

thanks for the reply krisd.

Actually i used the widget directly in the form. I did not write any code in the controller.

Do this for the name—>

// you must specify name or model/attribute


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]



Had this kind of problems before. I’ve used the yii debug toolbar extension 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.

is service_start_date a safe attribute?

Big Thanks to all. The datatime picker is working. I removed name attribute.


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.




	'value'=> date("d.m.Y H:i",$model->endtime),			



	'language' => 'de'


Any ideas are much appreciated!

Well, quite easy at the end, works with ‘name’ property instead of ‘mode’ and ‘attribute’.


	'value'=> date("d.m.Y H:i",$model->endtime),