department-of-veterans-affairs / va.gov-team

Public resources for building on and in support of VA.gov. Visit complete Knowledge Hub:
https://depo-platform-documentation.scrollhelp.site/index.html
281 stars 196 forks source link

[Documentation] Checkbox group example #12479

Open Mottie opened 4 years ago

Mottie commented 4 years ago

What is your documentation request, question, comment, or issue?

For the example on this page: https://department-of-veterans-affairs.github.io/veteran-facing-services-tools/forms/available-features-and-usage-guidelines#checkbox-group

  1. The screenshot doesn't match the code
  2. I think a more common usage for this pattern would include validation (even though HCA form doesn't have validation)
  3. We got it working using the following code:

    Click to expand ``` race: { 'ui:field': RaceEthnicityReviewField, 'ui:title': 'Which categories best describe you?', 'ui:description': 'You may check more than one.', isSpanishHispanicLatino: { 'ui:title': 'Spanish, Hispanic, or Latino', }, isAmericanIndianOrAlaskanNative: { 'ui:title': 'American Indian or Alaskan Native', }, isBlackOrAfricanAmerican: { 'ui:title': 'Black or African American', }, isNativeHawaiianOrOtherPacificIslander: { 'ui:title': 'Native Hawaiian or Other Pacific Islander', }, isAsian: { 'ui:title': 'Asian', }, isWhite: { 'ui:title': 'White', }, 'ui:required': () => true, 'ui:validations': [ (errors, fields) => { if ( !( fields.isSpanishHispanicLatino || fields.isAmericanIndianOrAlaskanNative || fields.isBlackOrAfricanAmerican || fields.isNativeHawaiianOrOtherPacificIslander || fields.isAsian || fields.isWhite ) ) { errors.addError('Choose at least one category'); } }, ], 'ui:options': { showFieldLabel: true, }, }, ```

    but a showFieldLabel is needed to get the validation to show up

  4. Lastly, adding that showFieldLabel option makes it include a second nested <fieldset> (without a legend) inside the outer one...

    Screenshot ![](https://user-images.githubusercontent.com/136959/90271037-ceea4200-de20-11ea-8f33-a1b6c44511e0.png)
taylorkaren commented 2 years ago

Work for ticket https://app.zenhub.com/workspaces/forms-library---platform-spike-team-61b0ae1f2cd3c30014e8a5b0/issues/department-of-veterans-affairs/formulate/127 will update check box documentation.