我正在为Yii2中的出生日期字段运行datePicker。我也在尝试显示年份。我已经检查了JQuery文档http://jqueryui.com/datepicker/#dropdown-month-year,我认为我可以使用实现此目的changeYear
。但这似乎不起作用。这是怎么做的?这是我当前的代码。
<?= $form->field($model, 'date_of_birth')->widget(DatePicker::className(),[
'name' => 'date_of_birth',
'language' => 'en-GB',
'dateFormat' => 'yyyy-MM-dd',
'options' => [
'changeMonth' => true,
'changeYear' => true,
'yearRange' => '1996:2099',
'showOn' => 'button',
'buttonImage' => 'images/calendar.gif',
'buttonImageOnly' => true,
'buttonText' => 'Select date'
],
]) ?>
您应该简单地使用clientOptions
而不是options
:
'clientOptions' => [
'changeMonth' => true,
'yearRange' => '1996:2099',
'changeYear' => true,
'showOn' => 'button',
'buttonImage' => 'images/calendar.gif',
'buttonImageOnly' => true,
'buttonText' => 'Select date'
],
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句