uhi67/yii2-datepicker
最新稳定版本:2.0
Composer 安装命令:
composer require uhi67/yii2-datepicker
包简介
Bootstrap 3 Date/time picker widget for Yii2
README 文档
README
A Yii2 date-time picker widget based on bower-asset/eonasdan-bootstrap-datetimepicker
Version 2.0
Limited BS4 compatibility, it just works
For Bootstrap 3 compatibility, use 1.x version.
Credits
Jonathan Peterson (@Eonasdan) for Bootstrap 3 Date/Time Picker. Antonio Ramirez (@tonydspaniard) for inspiration by Bootstrap DatePicker Widget for Yii2 and code examples. RomeroMsk for the previous version https://github.com/RomeroMsk/yii2-datepicker
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require "uhi67/yii2-datepicker":"^2.0"
or add
"uhi67/yii2-datepicker":"^2.0"
to the require section of your application's composer.json file.
Usage
Please refer to the Datepicker documentation web page for options and examples of using Eonasdan's Datepicker widget.
To use widget as date/time picker, set appropriate format, e.g. 'L LT' (as in examples below). See momentjs' docs for valid formats.
With a model
<?php
use uhi67\datepicker\DatePicker;
?>
<?= DatePicker::widget([
'model' => $model,
'attribute' => 'attrName',
'language' => 'ru',
'size' => 'lg',
'readonly' => true,
'placeholder' => 'Choose date',
'clientOptions' => [
'format' => 'L',
'minDate' => '2015-08-10',
'maxDate' => '2015-09-10',
],
'clientEvents' => [
'dp.show' => new \yii\web\JsExpression("function () { console.log('It works!'); }"),
],
]);?>
<?= $form->field($model, 'attrName')->widget(
DatePicker::className(), [
'addon' => false,
'size' => 'sm',
'clientOptions' => [
'format' => 'L LT',
'stepping' => 30,
],
]);?>
Without a model
<?php
use uhi67\datepicker\DatePicker;
?>
<?= DatePicker::widget([
'name' => 'datepickerTest',
'value' => '09/13/2015',
'clientOptions' => [
'format' => 'L',
],
'dropdownItems' => [
['label' => 'Yesterday', 'url' => '#', 'value' => \Yii::$app->formatter->asDate('-1 day')],
['label' => 'Tomorrow', 'url' => '#', 'value' => \Yii::$app->formatter->asDate('+1 day')],
['label' => 'Some value', 'url' => '#', 'value' => 'Special value'],
],
]);?>
Changes
2.0 -- 2021-10-20
- Bootstrap4 compatible version (limited)
1.0 -- 2021-10-20
- Version number is added
2020-01-10/uhi67
- Hungarian translations added
- Now works with DateTime and integer attribute values
2019-04-18/uhi67
- Now works with DateTime attribute values
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2021-10-20