https://github.com/alexantr/yii2-datetimepicker
Datetime picker input widget for Yii 2
https://github.com/alexantr/yii2-datetimepicker
datetime-picker datetimepicker flatpickr yii2 yii2-extension
Last synced: 8 months ago
JSON representation
Datetime picker input widget for Yii 2
- Host: GitHub
- URL: https://github.com/alexantr/yii2-datetimepicker
- Owner: alexantr
- License: mit
- Created: 2018-02-08T17:49:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-21T15:54:15.000Z (over 7 years ago)
- Last Synced: 2025-02-05T02:48:00.763Z (8 months ago)
- Topics: datetime-picker, datetimepicker, flatpickr, yii2, yii2-extension
- Language: PHP
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Datetime picker input widget for Yii 2
This extension renders an input with [flatpickr](https://chmln.github.io/flatpickr/).
[](https://packagist.org/packages/alexantr/yii2-datetimepicker)
[](https://packagist.org/packages/alexantr/yii2-datetimepicker)
[](https://raw.githubusercontent.com/alexantr/yii2-datetimepicker/master/LICENSE)## Installation
Install extension through [composer](http://getcomposer.org/):
```
composer require alexantr/yii2-datetimepicker
```## Usage
The following code in a view file would render an input with color picker:
```php
= alexantr\datetimepicker\DateTimePicker::widget(['name' => 'attributeName']) ?>
```If you want to use this input widget in an ActiveForm, it can be done like this:
```php
= $form->field($model, 'attributeName')->widget(alexantr\datetimepicker\DateTimePicker::className()) ?>
```Configuring the [flatpickr options](https://chmln.github.io/flatpickr/options/) should be done
using the `clientOptions` attribute:```php
= alexantr\datetimepicker\DateTimePicker::widget([
'name' => 'attributeName',
'clientOptions' => [
'allowInput' => false,
'enableTime' => false,
'enableSeconds' => false,
'dateFormat' => 'Y-m-d',
],
]) ?>
```By default widget uses flatpickr's options:
```php
[
'allowInput' => true,
'dateFormat' => 'Y-m-d H:i:S',
'enableTime' => true,
'enableSeconds' => true,
'minuteIncrement' => 1,
'time_24hr' => true,
]
```