yii2-flatpickr Datetime picker widget for Yii2 framework

Yii2 Flatpickr

  1. Installation
  2. Usage

https://github.com/Beaten-Sect0r/yii2-flatpickr

Flatpickr is a lightweight and powerful datetime picker.

Installation

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist beaten-sect0r/yii2-flatpickr "*"

or add

"beaten-sect0r/yii2-flatpickr": "*"

to the require section of your composer.json file.

Usage

<?php

use bs\Flatpickr\Widget as Flatpickr;

?>

<?= $form->field($model, 'published_at')->widget(Flatpickr::className(), [
    'locale' => strtolower(substr(Yii::$app->language, 0, 2)),
    '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,
    ],
]) ?>
1 0
2 followers
0 downloads
Yii Version: 2.0
License: BSD-2-Clause
Category: Date and Time
Tags: flatpickr
Developed by: Beaten_Sect0r
Created on: Apr 22, 2017
Last updated: 6 years ago

Related Extensions