bigfork / silverstripe-simpledatefield
一个基于英国政府日期输入格式的 SilverStripe 表单字段,用于输入日期
1.1.0
2024-07-05 08:49 UTC
Requires
- ext-intl: *
- silverstripe/framework: ^4 || ^5
This package is auto-updated.
Last update: 2024-08-27 21:22:29 UTC
README
一个基于 GOV.UK 设计系统 日期输入模式 的表单字段,该模式使用三个独立的输入框来输入日、月和年。
使用方法
SimpleDateField::create('DateOfBirth', 'Date of birth'); // Or to offer the inputs in a different order SimpleDateField::create('DateOfBirth', 'Date of birth', null, SimpleDateField::YMD); SimpleDateField::create('DateOfBirth', 'Date of birth', null, SimpleDateField::MDY);
如果您选择手动传递日期给 $value
参数,它必须是 ISO 6801 日期格式(YYYY-MM-DD)。
出生日期
如果您使用此字段允许用户输入出生日期,建议添加相关的 autocomplete
属性以提供帮助。
$field = SimpleDateField::create('DateOfBirth', 'Date of birth'); $field->getDayField()->setAttribute('autocomplete', 'bday-day'); $field->getMonthField()->setAttribute('autocomplete', 'bday-month'); $field->getYearField()->setAttribute('autocomplete', 'bday-year');
样式
没有提供前端样式来显示“内联”字段。您可以使用 CMS 样式作为灵感:查看 client/src/bundles/cms.scss
。
待办事项
- 添加标签/错误消息的翻译实体
- 最小/最大日期选项
- 单元测试