Looking at the documentation for the plugin, the Kartik Widget is based on the fact that you do what you want, it seems impossible, but Yii2 already has this functionality built-in :
1, Add this css to hide everything in the calendar widgets except year
<style type="text/css"> .ui-datepicker-calendar { display: none; } </style>
2, use the Yii built-in widget, change class and model names to reflect your actual project
echo $form->field($model, 'time_scheduled')->widget(\yii\jui\DatePicker::classname(), [ 'clientOptions' => [ 'changeMonth' => false, 'changeYear' => true, 'showButtonPanel' => true, 'dateFormat' => 'yyyy', 'yearRange' => '1990:2020' ], ]);
3, when testing, I found that I need to add this javascript too (but there may be a better way)
$(document.body).on('click', '.ui-datepicker-close', function (e) { var value = $('.ui-datepicker-year :selected').text(); $('#feed-time_scheduled').val(value); });
Yii uses bootprap datepicker, and opions for this is here .
source share