Adrianna
(Rhea Uplb)
May 14, 2014, 12:32am
1
How can I add days in CJuiDatePicker? I want to store default value = current date + 7days.
This is my code but it only display date today.
$this->beginWidget('zii.widgets.jui.CJuiDatePicker', array(
'id'=>'date_opening',
'model'=>$model,
'attribute'=>'date_opening',
'name'=>'date_opening',
'htmlOptions'=>array('required'=>'required', 'value'=>date('m/d/y')),
));
$this->endWidget();
Thank you
jkofsky
(Jkofsky)
May 14, 2014, 6:20am
2
adrianna:
How can I add days in CJuiDatePicker? I want to store default value = current date + 7days.
This is my code but it only display date today.
$this->beginWidget('zii.widgets.jui.CJuiDatePicker', array(
'id'=>'date_opening',
'model'=>$model,
'attribute'=>'date_opening',
'name'=>'date_opening',
'htmlOptions'=>array('required'=>'required', 'value'=>date('m/d/y')),
));
$this->endWidget();
Thank you
‘value’, or ‘defaultValue’, goes in the ‘options’=>array() param for JuiDatePicker not in the htmlOptions. If you look at the source code in the browser you probably see “value”=“05/09/20014” in one of html tags involved with the widget.
paalgg
(Paalgg)
May 14, 2014, 6:22am
3
Suggestion:
$date = new DateTime(); // Todays date
$interval = new DateInterval('P7D'); // Periode of 7 days
$date->add($interval); // $date is not 7 days ahead
Put $date->format(‘Y-m-d’) into your code:
$this->beginWidget('zii.widgets.jui.CJuiDatePicker', array(
'id'=>'date_opening',
'model'=>$model,
'attribute'=>'date_opening',
'name'=>'date_opening',
'value'=>$date->format('Y-m-d'),
'htmlOptions'=>array('required'=>'required', 'value'=>date('m/d/y')),
));
Adrianna
(Rhea Uplb)
May 14, 2014, 7:05am
4
jkofsky:
‘value’, or ‘defaultValue’, goes in the ‘options’=>array() param for JuiDatePicker not in the htmlOptions. If you look at the source code in the browser you probably see “value”=“05/09/20014” in one of html tags involved with the widget.
Thank you. I didn’t notice it at first. I would move it to option param
Adrianna
(Rhea Uplb)
May 14, 2014, 8:27am
5
Suggestion:
$date = new DateTime(); // Todays date
$interval = new DateInterval('P7D'); // Periode of 7 days
$date->add($interval); // $date is not 7 days ahead
Put $date->format(‘Y-m-d’) into your code:
$this->beginWidget('zii.widgets.jui.CJuiDatePicker', array(
'id'=>'date_opening',
'model'=>$model,
'attribute'=>'date_opening',
'name'=>'date_opening',
'value'=>$date->format('Y-m-d'),
'htmlOptions'=>array('required'=>'required', 'value'=>date('m/d/y')),
));
This works for me. Thank you.