Skip to content

Pass values to date-input when using default items #1154

@penx

Description

@penx

At the moment there is no way to pass values (or field-level error states/CSS classes) to the date-input when using the default item set. This means you have to redefine the items param, including CSS classes for widths, whenever the date-input is used. This encourages repeated code and is arguably more prone to error.

Is it worth having a values param and an errors param on date-input? This could fall back to values/errors passed via the items param for backward compatibility, but favouring the new items/errors props.

e.g.

{{ govukDateInput({
  id: "dob",
  namePrefix: "dob",
  values: {
    day: 4,
    month: 5,
    year: 20t19
  },
  errorMessage: 'Please enter a valid year',
  errors: {
    year: true
  }
}) }}

I don't have an immediate need for this but it's something I noticed and thought worth suggesting in case others agree.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions