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

Use of datepicker date component in yii

王林
王林Original
2019-12-24 14:19:402222browse

Use of datepicker date component in yii

1. Installation of date component

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

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, 
    ] 
]); ?>

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;, 
    ] 
]); ?>

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!

Statement:
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