The example in this article describes how the Yii2 framework refers to the date plug-in yii2-date-picker in bootstrap. Share it with everyone for your reference, the details are as follows:
I have been learning the yii2 framework recently and found that the framework is very powerful and incorporates many new technologies nowadays.
Briefly record how to use the yii2-date-picker plug-in:
First, understand the relevant resources in github: https://github.com/2amigos/yii2-date-picker-widget
Second: Use it yourself In the project, use the relevant method in the link above to download this resource. The command is:
php composer.phar require "2amigos/yii2-date-picker-widget" "*"
Finally, use the following in the view file Code:
use dosamigosdatepickerDatePicker;
The example provides two methods:
Method 1. Using widget method
<?= DatePicker::widget([ 'model' => $model, 'attribute' => 'date', 'template' => '{addon}{input}', 'clientOptions' => [ 'autoclose' => true, 'format' => 'dd-M-yyyy' ] ]);?>
Method 2. ActiveForm method
<?= $form->field($model, 'date')->widget( DatePicker::className(), [ // inline too, not bad 'inline' => true, // modify template for custom rendering 'template' => '<div>{input}</div>', 'clientOptions' => [ 'autoclose' => true, 'format' => 'dd-M-yyyy' ] ]);?>
I hope this article will be helpful to everyone based on Yii framework for PHP programming helps.
The above introduces the method of Yii2 framework to reference the date plug-in yii2-date-picker in bootstrap, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.