matthew-p / yii2-working-date-time-widget
为yii2的工时和日期输入小部件。
1.0
2018-01-04 10:33 UTC
Requires
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-09-19 22:14:39 UTC
README
输入日期/时间/餐时间小部件
安装
安装此扩展的首选方式是通过 Composer。
运行以下命令之一:
php composer.phar require --prefer-dist matthew-p/yii2-working-date-time-widget "*"
或者
"matthew-p/yii2-working-date-time-widget": "*"
将其添加到您的 composer.json
文件的 require 部分。
使用方法
扩展安装完成后,只需在代码中简单使用即可
<?= \MP\WorkingDatetime\WorkingDays::widget(['name' => 'example']); ?>
选项
WorkingDays::widget([ 'name' => 'example', 'roundTheClock' => '00.00 - 00.00', // Default - 00.00 - 00.00. Round-The-Clock value 'enableDinner' => true, // Default - true. Enable/disable dinner input 'autocompleteDays' => [], // Default - []. Automatic filling of time for the specified days // Example: [1,2,5] or ['monday', 'friday'] // Warning: FILLS TIME FROM THE FILLED DAY ])
如果您动态地将小部件添加到页面,运行(js)
MPWorkingDays.reInit(); // Set default settings only for NEW widgets
或者
MPWorkingDays.reInit({newId: 'oldId'}); // Copy settings from previous widget
或者
MPWorkingDays.reInit({newId: {settings...}}); // Set new widget settings
动态设置小部件设置
MPWorkingDays.addInputSettings(widgetID, {settings...});
Yii2模型所需验证器
/** * @inheritdoc */ public function rules() { return [ ['workday', WorkingDaysRequiredValidator::class] ]; }