my6uot9 / yii2-flatpickr
Datetime picker widget for Yii2 framework
Installs: 127
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 11
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: ~2.0.14
README
Flatpickr is a lightweight and powerful datetime picker.
Changes from mix8872/yii2-flatpickr
-
Dropped asset-packagist, only use npm To be able to use
composer install
in this standalone yii2-flatpickr, add to composer.json:"replace": { "bower-asset/jquery": "*", "bower-asset/inputmask": "*", "bower-asset/punycode": "*", "bower-asset/yii2-pjax": "*" }
That tells composer, that those packages are already provided. Thus effectively preventing them from installing.
-
Replaced glyphicons with fontawesome
Installation
The preferred way to install this extension is through composer.
Either run
composer require --prefer-dist my6uot9/yii2-flatpickr "^3.0.0"
or add
"my6uot9/yii2-flatpickr": "^3.0.0"
to the require section of your composer.json
file.
Installation of Assets
The preferred way to install the required assets is through nodejs.
npm install flatpickr@^4.6.3
or add
"flatpickr": "^4.6.3"
to the dependencies section of your package.json
file.
Usage
By default the confirmDate plugin is active and configured like this:
'plugins' => [
'confirmDate' => [
'confirmIcon'=> "<i class='fa fa-check'></i>",
'confirmText' => 'OK',
'showAlways' => false,
'theme' => 'light',
],
],
Visit https://chmln.github.io/flatpickr/plugins/ for more plugins and config infos.
- The locale is automatically set to
strtolower(substr(Yii::$app->language, 0, 2));
.
It can be overwritten by settinglocale
directly. - Only one theme can be used at a time,
<?php use my6uot9\Flatpickr\FlatpickrWidget; ?> <?= $form->field($model, 'published_at')->widget(FlatpickrWidget::class, [ 'locale' => 'fr', //default is strtolower(substr(Yii::$app->language, 0, 2)) // 'clear' => false, // renders reset button, default is true 'toggle' => true, // renders button to open calendar, default is false 'clientOptions' => [ // config options https://chmln.github.io/flatpickr/options/ 'allowInput' => false, //default is true 'defaultDate' => $model->published_at ? date(DATE_ATOM, $model->published_at) : null, 'enableTime' => true, //default is false ], ]) ?>