组件说明
日期时间组件用于选择日期和时间,支持精确到秒的时间选择。
用法示例
use plugin\xbCode\builder\Builder;
use plugin\xbCode\builder\Renders\Form;
Builder::form(function (Form $builder) {
// 基础用法
$builder->addRowDateTime('datetime', '日期时间', '', function($component) {
$component->format('YYYY-MM-DD HH:mm:ss');
$component->placeholder('请选择日期时间');
$component->clearable(true);
});
// 带快捷选项
$builder->addRowDateTime('publish_time', '发布时间', '', [
'shortcuts' => ['now', 'today', 'yesterday'],
'minDate' => '${TODAY}',
'closeOnSelect' => false
]);
});
组件参数
| 参数名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| name | string | - | 字段名称 |
| label | string | - | 字段标签 |
| value | string | - | 默认值 |
| valueFormat | string | 'YYYY-MM-DD HH:mm:ss' | 日期时间值格式 |
| displayFormat | string | - | 显示格式 |
| placeholder | string | - | 占位文本 |
| shortcuts | array | - | 快捷键 |
| minDate | string | - | 限制最小日期时间 |
| maxDate | string | - | 限制最大日期时间 |
| clearable | bool | false | 是否可清除 |
| closeOnSelect | bool | true | 选择后是否关闭 |
| required | bool | false | 是否必填 |
| disabled | bool | false | 是否禁用 |
使用说明
- 日期时间组件是日期组件的扩展,包含时分秒选择
- shortcuts支持:now、today、yesterday等
- valueFormat默认为'YYYY-MM-DD HH:mm:ss'