yii2 Yii2 Jquery Calendar For Text Field Add jquery calendar for a text field with max as current date

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9


If we want to display a jquery calendar for end user who can pick maximum date as current date in the calendar. The below code will useful to this scenario.

use yii\jui\DatePicker;
use yii\widgets\ActiveForm;

<?php $form = ActiveForm::begin(['id' => 'profile-form']); ?>
<?= $form->field($model, 'date_of_birth')->widget(DatePicker::classname(), ['dateFormat' => 'php:M d, Y', 'options' => ['readonly' => true], 'clientOptions' => [ 'changeMonth' => true, 'changeYear' => true, 'yearRange' => '1980:'.date('Y'), 'maxDate' => '+0d']]) ?>
<?php ActiveForm::end(); ?>

Got any yii2 Question?