This article mainly introduces the method of referencing the date plug-in yii2-date-picker in bootstrap in the Yii2 framework, and analyzes the specific steps and related skills of the yii2-date-picker plug-in, A friend can refer to the example of this article describes the Yii2 framework reference bootstrap date plug-in yii2-date-picker method. We will share this with you for your reference. The details are as follows:
I recently learned about the yii2 framework and found that the framework is very powerful, and it integrates many new technologies.
A simple record of the use of the yii2-date-picker plug-in:
First understand the relevant resources in github: https://github.com/2amigos/yii2-date-picker-widget
Second, use the method in the above link to download this resource in your project. the command is:
Php composer. phar require "2 amigos/yii2-date-picker-widget ""*"
Finally, use the following code in the view file:
Use dosamigos \ datepicker \ DatePicker;
Two methods are provided in the example:
Method 1. use widgets
<?= DatePicker::widget([ 'model' => $model, 'attribute' => 'date', 'template' => '{addon}{input}', 'clientOptions' => [ 'autoclose' => true, 'format' => 'dd-M-yyyy' ]]);?>
Method 2. ActiveForm
<?= $form->field($model, 'date')->widget( DatePicker::className(), [ // inline too, not bad 'inline' => true, // modify template for custom rendering 'template' => '{input}
', 'clientOptions' => [ 'autoclose' => true, 'format' => 'dd-M-yyyy' ]]);?>
I hope this article will help you design PHP programs based on the Yii Framework.