Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow values for the default date input #4932

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joelanman
Copy link
Contributor

@joelanman joelanman commented Apr 11, 2024

If you don't pass items to govukDateInput, it renders the default Day, Month and Year that most people need. However you commonly need to set the values, at which point you have to set all the items individually.

This PR adds a values option similar to other components that allows you to pass an array of values. In usage this looks like:

{{ govukDateInput({
  id: "passport-issued",
  namePrefix: "passport-issued",
  values: [data['passport-issued-day'],
           data['passport-issued-month'],
           data['passport-issued-year']],
  fieldset: {
    legend: {
      text: "When was your passport issued?",
      isPageHeading: true,
      classes: "govuk-fieldset__legend--l"
    }
  },
  hint: {
    text: "For example, 27 3 2007"
  }
}) }}

The only thing still missing would be to have error states, which could be tricky. You could have a similar classes option, but then you'd have to set govuk-input--width too, at which point the code is pretty much as verbose as setting items individually. However for prototyping I don't think you would always need error states.

@joelanman
Copy link
Contributor Author

joelanman commented Apr 11, 2024

thinking some more, if the main value here is for prototyping, it might be better to look into an option to automatically set all values based on names in the kit (no need to manually set values at all), I think @36degrees did an investigation into that a while back

Update:

Here is the investigation:

alphagov/govuk-prototype-kit#1316

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant