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

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

Open
penx opened this issue Jan 21, 2019 · 2 comments
Open

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

penx opened this issue Jan 21, 2019 · 2 comments

Comments

@penx
Copy link

penx commented Jan 21, 2019

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.

@kellylee-gds kellylee-gds added Priority: Low and removed awaiting triage Needs triaging by team labels Jan 23, 2019
@frankieroberto
Copy link
Contributor

I just faced this issue too (when using the Prototyping Kit). It's a requirement when implementing the "Check your answers" pattern, as that allows people to go back and edit their dates, so you need to be able to set the values from their previous answer.

@edwardhorsford
Copy link
Contributor

Just faced this issue as well. Would be great if there were an easier way of setting default value - though I appreciate this may be tricky.

In the short term I wonder if the default example / most examples should include the items array - nearly all services will have to have it to be able to let users change existing answers / do validation.

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

No branches or pull requests

8 participants