Skip to content

codenix-sv/yii2-flatpickr

Repository files navigation

Flatpickr widget for Yii2

Build Status Maintainability Test Coverage Scrutinizer Code Quality Code Coverage

License Latest Stable Version

This is Yii2 widget wrapper for Flatpickr datetime picker. Flatpickr is a lightweight and powerful datetime picker written in vanilla javascript.

flatpickr-theme flatpickr-theme-dark

Latest release

The latest stable version of the extension is v2.0

Installation

The preferred way to install this extension is through composer.

Either run

$ composer require codenix-sv/yii2-flatpickr:~2.0

or add

"codenix-sv/yii2-flatpickr" : "~2.0"

to the require section of your application's composer.json file.

Basic usage

Example of use with an ActiveForm:

<?php

use codenixsv\flatpickr\Flatpickr;

?>
...
<?= $form->field($model, 'date')->widget(Flatpickr::class) ?>

Example of use as a widget:

<?= Flatpickr::widget(['model' => $model, 'attribute' => 'email']) ?>

Usage with options

<?php

use codenixsv\flatpickr\Flatpickr;

?>
...
<?= $form->field($model, 'email')->widget(Flatpickr::class, [
        'theme' =>'dark',
        'clientOptions' => [
            'locale' => 'ru',
            'enableTime' => true
        ]
]) ?>

Further Information

Please, check the Flatpickr site documentation for further information about configuration options.

License

yii2-flatpickr is released under the MIT License. See the bundled LICENSE for details.