[extension] cgsmith/yii2-flatpickr-widget


Flatpickr JS Widget for Yii2

  1. Installation
  2. Usage
  3. Resources Information
  4. Contributing
  5. Credits
  6. License





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.