The Yii2 framework refers to the method of the date plug-in yii2-date-picker in bootstrap

WBOY
Release: 2016-07-29 09:07:09
Original
984 people have browsed it

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

<&#63;= DatePicker::widget([
  'model' => $model,
  'attribute' => 'date',
  'template' => '{addon}{input}',
    'clientOptions' => [
      'autoclose' => true,
      'format' => 'dd-M-yyyy'
    ]
]);?>

Copy after login

Method 2. ActiveForm method

<&#63;= $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'
    ]
]);?>

Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!