alexantr/yii2-datetimepicker

Datetime picker input widget for Yii 2

Installs: 6 110

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 1

Type:yii2-extension

1.1.1 2018-06-21 15:53 UTC

This package is auto-updated.

Last update: 2024-11-23 15:39:58 UTC


README

This extension renders an input with flatpickr.

Latest Stable Version Total Downloads License

Installation

Install extension through composer:

composer require alexantr/yii2-datetimepicker

Usage

The following code in a view file would render an input with color picker:

<?= alexantr\datetimepicker\DateTimePicker::widget(['name' => 'attributeName']) ?>

If you want to use this input widget in an ActiveForm, it can be done like this:

<?= $form->field($model, 'attributeName')->widget(alexantr\datetimepicker\DateTimePicker::className()) ?>

Configuring the flatpickr options should be done using the clientOptions attribute:

<?= alexantr\datetimepicker\DateTimePicker::widget([
    'name' => 'attributeName',
    'clientOptions' => [
        'allowInput' => false,
        'enableTime' => false,
        'enableSeconds' => false,
        'dateFormat' => 'Y-m-d',
    ],
]) ?>

By default widget uses flatpickr's options:

[
    'allowInput' => true,
    'dateFormat' => 'Y-m-d H:i:S',
    'enableTime' => true,
    'enableSeconds' => true,
    'minuteIncrement' => 1,
    'time_24hr' => true,
]