A SilverStripe form field for entering dates based on the UK Government’s date input pattern
A form field for entering dates based on the GOV.UK Design Systemâs date input pattern, which uses three separate inputs for day, month, and year.
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);
If you choose to manually pass a date to the $value
argument, it must be in the ISO 6801 date format (YYYY-MM-DD).
If using this field to allow users to enter their date of birth, itâs recommended to add relevant autocomplete
attributes to assist this.
$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');
No front-end styling is provided to display the fields âinlineâ. You could use the CMS styling for inspiration: check out client/src/bundles/cms.scss
.
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem