use a label with yii2 DatePicker

2.2k Views Asked by At

I am using yii2 DatePicker and want to use some lable as "Schedule Date" with date picker field in Active form. Another thing I want that the default date should be current date selected and disable the previous dates/days.

Thanks in advance to solve my problem

My Date picker code is here

<?php
echo DatePicker::widget([
'model' => $model,
'attribute' => 'BS_ScheduledDate',
'dateFormat' => 'yyyy-MM-dd',
]);
?>
1

There are 1 best solutions below

0
On

This is used disable previous dates

<?= $form->field($model, 'Date')->widget(\yii\jui\DatePicker::classname(), [
                           'language' => 'en',
                           'options' => ['autocomplete'=>'off','readOnly'=>true],
                            'clientOptions'=>[
                              'changeMonth'=>true,
                              'changeYear'=> true,
                              'yearRange'=> "+0:+50",
                              'minDate'=> "+0",
                              'dateFormat' => 'dd/mm/yy',
                            ],
                      ])->label(false); ?>

And use below model function for setting labels

public function attributeLabels()