Flatpickr JS Widget for Yii2 ¶
Renders a flatpickr Datepicker plugin.
Installation ¶The preferred way to install this extension is through composer.
Either run
$ composer require cgsmith/yii2-flatpickr-widget:~1.0
or add
"cgsmith/yii2-flatpickr-widget": "~1.0"
to the require section of your application's composer.json
file.
Usage ¶The widget renders the flatpickr onto your form.
Example of use with a form
Use the widget by setting up its model
and attribute
.
<?php
use cgsmith\flatpickr\FlatpickrWidget;
// as a widget
?>
<?= FlatpickrWidget::widget([
'model' => $model,
'attribute' => 'date',
]);?>
<?php
// additional config options for flatpickr
echo $form->field($model, 'date')->widget(
FlatpickrWidget::widget([
'model' => $model,
'attribute' => 'date',
'flatpickrConfig' => [ // This is passed as a JSON object to flatpickr
'enableTime' => false,
'dateFormat' => 'F j, Y H:i',
'altInput' => true,
'altFormat' => 'F j, Y',
]
]);
?>
Resources Information ¶Please, check the flatpicker site documentation for further information about its configuration options.
Contributing ¶Contributions are welcome!
Credits ¶
License ¶The BSD License (BSD). Please see License File for more information.