beaten-sect0r / yii2-flatpickr
为 Yii2 框架的日期时间选择器小部件
2.0.1
2017-11-02 15:15 UTC
Requires
- bower-asset/flatpickr: ^3.0
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-09-25 23:24:11 UTC
README
点击一个 ⭐!
Flatpickr 是一个轻量级且功能强大的日期时间选择器。
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一:
composer require --prefer-dist beaten-sect0r/yii2-flatpickr "*"
或者
"beaten-sect0r/yii2-flatpickr": "*"
将以下内容添加到您的 composer.json
文件的 require 部分。
使用方法
<?php use bs\Flatpickr\FlatpickrWidget; ?> <?= $form->field($model, 'published_at')->widget(FlatpickrWidget::class, [ 'locale' => strtolower(substr(Yii::$app->language, 0, 2)), // https://chmln.github.io/flatpickr/plugins/ 'plugins' => [ 'confirmDate' => [ 'confirmIcon'=> "<i class='fa fa-check'></i>", 'confirmText' => 'OK', 'showAlways' => false, 'theme' => 'light', ], ], 'groupBtnShow' => true, 'options' => [ 'class' => 'form-control', ], 'clientOptions' => [ // config options https://chmln.github.io/flatpickr/options/ 'allowInput' => true, 'defaultDate' => $model->published_at ? date(DATE_ATOM, $model->published_at) : null, 'enableTime' => true, 'time_24hr' => true, ], ]) ?>