alexantr / yii2-datetimepicker
Datetime picker input widget for Yii 2
Installs: 6 000
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 1
Type:yii2-extension
Requires
- npm-asset/flatpickr: ^4.3
- yiisoft/yii2: ~2.0.6
This package is auto-updated.
Last update: 2024-10-23 15:33:59 UTC
README
This extension renders an input with flatpickr.
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, ]