Home > PHP Framework > YII > Use of datepicker date component in yii

Use of datepicker date component in yii

王林
Release: 2019-12-24 14:19:40
Original
2267 people have browsed it

Use of datepicker date component in yii

1. Installation of date component

composer require kartik-v/yii2-widget-datepicker "@dev"
Copy after login

2. Use of date component

use kartik\date\DatePicker; 
<?php echo DatePicker::widget([ 
    &#39;name&#39; => &#39;Article[created_at]&#39;, 
    &#39;options&#39; => [&#39;placeholder&#39; => &#39;...&#39;], 
    //value值更新的时候需要加上 
    &#39;value&#39; => &#39;2016-05-03&#39;, 
    &#39;pluginOptions&#39; => [ 
        &#39;autoclose&#39; => true, 
        &#39;format&#39; => &#39;yyyy-mm-dd&#39;, 
        &#39;todayHighlight&#39; => true, 
    ] 
]); ?>
Copy after login

The usage of date component generated by ActiveForm is as follows :

<?= $form->field($model, &#39;created_at&#39;)->widget(DatePicker::classname(), [ 
    &#39;options&#39; => [&#39;placeholder&#39; => &#39;&#39;], 
    &#39;pluginOptions&#39; => [ 
        &#39;autoclose&#39; => true, 
        &#39;todayHighlight&#39; => true, 
        &#39;format&#39; => &#39;yyyy-mm-dd&#39;, 
    ] 
]); ?>
Copy after login

Rendering:

Use of datepicker date component in yii

Recommended related articles and tutorials: yii tutorial

The above is the detailed content of Use of datepicker date component in yii. For more information, please follow other related articles on the PHP Chinese website!

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