Method for referencing the date plug-in yii2-date-picker in bootstrap in the Yii2 framework

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.