Improve UX of validation/constraints for daterange field

Created on 26 November 2023, over 1 year ago

Problem/Motivation

In the work on ✨ Allow end date to be optional Needs review we saw some problems with DateRange validation UX. At the moment the error "This value should not be null", and the way the field errors are highlighted, is confusing. This ticket can be worked on in isolation of ✨ Allow end date to be optional Needs review but it's probably easier as a follow up.

Steps to reproduce

  1. Standard profile
  2. Install daterange module
  3. Add a daterange field to *page* node, make it *not required*
  4. Go to /node/add and start to create a page
  5. Leave the start date empty. End the end date. (Reverse has the same outcome)
  6. (Making sure to add required fields like title then) submit.

Current: "This value should not be null" error, and both fields are highlighted red.

Expected: "You must add a start date" or "You must add both dates" and only the start date should be highlighted red.

Proposed resolution

At the moment this gets a NotNull constraint and if you don't enter either date you get a more user friendly HTML5 validation. I think the daterange module should have it's own specialised constraint, especially as we make the end date (and later start date) optional.

If ✨ Allow end date to be optional Needs review is finished it should cover optional end dates.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component
DatetimeΒ  β†’

Last updated about 18 hours ago

Created by

πŸ‡¦πŸ‡ΊAustralia sime Melbourne

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024