Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii2 Kartik DatePicker - Date should not exceed current date

Is there a way in kartik DatePicker Yii2 - by which I can disable the dates that are greater than current date?

For example: if today is 14th march 2016 then calendar dates from 15th march 2016 should be disabled.

Thanks :)

like image 763
Danish Ahmed Avatar asked Oct 17 '25 10:10

Danish Ahmed


1 Answers

Plugin Demo page says "DatePicker widget is a Yii2 wrapper for the Bootstrap DatePicker plugin". So you can use all bootstrap datepicker options in this plugin.It should come under "pluginOptions" as key value pair.

"endDate" => "0d", // Will disable all dates after today.

echo DatePicker::widget([
  'type' => DatePicker::TYPE_INPUT,
  'pluginOptions' => [
      'autoclose'=>true,
      'format' => 'dd-M-yyyy',
      'endDate' => "0d"
  ]
]);

Bootstrap Datepicker Doc

like image 197
ck_arjun Avatar answered Oct 21 '25 23:10

ck_arjun