Cjuidatepicker - Set Current Date On Picker Binded With Model?

$this->widget('zii.widgets.jui.CJuiDatePicker', array(

'model' => $deadline,

'attribute' => 'end_time',

'flat' => true,


My form loads normally, and CJuidatepicker shows current date.

But when I make a mistake in form and validation occurs, after showing error summary my CJuiddatepicker shows last possible date!

I understand it is because my model attribute $deadline->end_time is not set - because of the errors, and it is

1970-01-01 00:00:00.

How to make it ‘remember’ which date user has selected, even if he entered other information incorrectly?

Maybe date validators? Can I make it return an error if selected day is in past? I only need future dates to be entered…

you can assign the end_date value from your post to the model attribute before you do the validation check

I will try that, it is a multi model saving function, I will look into it.

While we’re at it, there are parts of form which are loaded when user clicks button (ajax), and new model instances are added into an array of models. When there is an error on form and page gets refreshed (just like datepicker) all model data that is entered into ajax loaded parts of form disappears.

Is this something like this:

$model1 = new car();

$model2 = new tyre();

$donations[] = new carparts(); //to this array I add by calling and ajax from client side


$valid = model1->validate();

$valid = $valid && model2->validate();





//also parts loaded via ajax into a array of models

foreach($donations as $donation)