Reputation: 25
Can anyone tell me why it is not working for me?
Actual question: When browsing dates in the date picker, a default day has to be selected if no selection is done.
I did it manually in the Jquery Datepicker but in YII using Zii Widget i am not getting.
$this->datePickerOptions = array(
'showAnim' => 'fold',
'dateFormat'=>'dd M yy',
'changeMonth' => 'true',`enter code here`
'changeYear'=>'true',
'constrainInput' => 'false',
'firstDay' => 1,
'onChangeMonthYear' => 'js:function (year, MM, inst) {
var selectedDate = new Date();
_currentDay=this.value.toString().substr(0,2);
selectedDate = Date.parse(MM + "" + _currentDay + " " + year );
this.value=selectedDate.toString("dd MMM yyyy");
}'
Upvotes: 0
Views: 422
Reputation: 25
'onChangeMonthYear'=>'js:function(y, m, i){
var d = i.selectedDay;
$(this).datepicker("setDate", new Date(y, m - 1, d));
}'
like this i fixed the problem, now when i am changing the month and year in text field also changing the dates. thank you..
Upvotes: 1
Reputation: 820
You can try to set a default. If nothing has changed during selection time, the default will remain untouched.
'defaultDate'=>'0000-00-00',
Upvotes: 0