承接 cgsmith/yii2-flatpickr-widget 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cgsmith/yii2-flatpickr-widget

最新稳定版本:1.1.0

Composer 安装命令:

composer require cgsmith/yii2-flatpickr-widget

包简介

flatpickr (DatePicker) widget for Yii2.

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version 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.1

or add

"cgsmith/yii2-flatpickr-widget": "~1.1"

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',
        'locale' => 'ru', // optional
    ]
]);
?>

Example

It's not a demo without a GIF

Example of use on Gridview You may need to adjust the filter to work with your form or search model but this is how it is working with a default Yii installation.

<?php
    echo GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            [
                'attribute' => 'created_at',
                'label' => 'Created At',
                'format' => 'datetime',
                'value' => 'created_at',
                'filter' => \cgsmith\flatpickr\FlatpickrWidget::widget(
                    [
                        'model' => $searchModel,
                        'attribute' => 'created_at',
                        'flatpickrConfig' => [
                                'enableTime' => false,
                                'dateFormat' => 'U',
                                'altInput' => true,
                                'altFormat' => 'F j, Y',
                        ],
                    ]
                )
            ],
            'updated_at:datetime',
            // other columns and settings for gridview
        ],
    ]);

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.

统计信息

  • 总下载量: 1.19k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2022-12-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固