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

subtype value silently dropped when saving formBuilder when subtype field is not available #1415

Open
lucasnetau opened this issue Sep 14, 2023 · 0 comments
Labels

Comments

@lucasnetau
Copy link
Collaborator

lucasnetau commented Sep 14, 2023

          I just figured that once you saved the form and loaded again, the fields get lost from the ui. That's because the checkbox group does not have the Type dropdown with the subtype. I'm looking to see if that's possible to add it, that way the declared subtype is still in the element once saved/loaded.

Originally posted by @parrainc in #1168 (comment)

A checkbox-group/radio can be added with a subtype defined. This allows subtype userAttributes to be applied:

{
      type: 'checkbox-group',
      subtype: 'custom-group',
      label: 'Custom Checkbox Group w/Sub Type',
      required: true,
      values: [
        { label: 'Option 1' },
        { label: 'Option 2' }
      ]
}

However because this control does not show a subtype attribute in the stage (guess is because controls.registeredSubtypes does not return subtypes defined in opts.subtypes) the value is lost when saving the formdata

{
      type: 'checkbox-group',
      label: 'Custom Checkbox Group w/Sub Type',
      required: true,
      values: [
        { label: 'Option 1' },
        { label: 'Option 2' }
      ]
}

Thoughts so far:

  • Use config.subtypes instead of controls.registeredSubtypes to decide on showing the subtype dropdown
  • For control select.js need to ensure that when building we use the type and not subtype for rendering due to this code in control.js
    // if subtype, update the config type for injecting into DOM elements
    if (this.subtype) {
      config.type = this.subtype
    }
@lucasnetau lucasnetau added the bug label Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant