有谁能告诉我为什么它不适合我?
实际问题:在日期选择器中浏览日期时,如果没有选择,则必须选择默认日期。
我是在Jquery Datepicker中手动完成的,但在YII中使用Zii Widget我不是 得到。
$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");
}'
答案 0 :(得分:1)
'onChangeMonthYear'=>'js:function(y, m, i){
var d = i.selectedDay;
$(this).datepicker("setDate", new Date(y, m - 1, d));
}'
像这样我修复了问题,现在当我在文本字段中更改月份和年份时也会更改日期。
谢谢..
答案 1 :(得分:0)
您可以尝试设置默认值。如果在选择时间内没有任何变化,则默认值保持不变。
'defaultDate'=>'0000-00-00',