formkit icon indicating copy to clipboard operation
formkit copied to clipboard

Togglebuttons with multiple attribute returns array of selected strings when on-value is set

Open Rednas83 opened this issue 1 year ago • 3 comments

Reproduction

https://formkit.link/11fdabf047e7c0ae953929f4217fdd6b

Describe the bug

Expected result Similar to Standalone Toggle when off-value=false and on-value=true

{
  "pizza_toppings": {
    Pepperoni: true,
    Sausage: true,
    Mushroom: false,
    Olives: false,
  }
}

Instead of Perhaps return this when on-value=null to also support array of selected strings?

{
  "pizza_toppings": [
    "Pepperoni",
    "Sausage"
  ]
}

Environment

------------------------------
- Operating System: Windows_NT
- Node Version:     v20.12.2
- Nuxt Version:     3.11.2
- CLI Version:      3.11.1
- Nitro Version:    2.9.6
- Package Manager:  [email protected]
- Builder:          -
- User Config:      telemetry, modules, icon, build, routeRules, components, content, formkit, imports, css, devtools
- Runtime Modules:  @vueuse/[email protected], normalizedModule(), @nuxt/[email protected], @pinia/[email protected], @nuxtjs/[email protected], [email protected], @formkit/[email protected]
- Build Modules:    -
------------------------------

Rednas83 avatar Jun 03 '24 09:06 Rednas83

@Rednas83 This is a little bit too much of a departure from the way preexisting inputs with the multiple prop and array of values currently work (checkbox, dropdown-family inputs, transferlist). I don't think this is something we'll be supporting.

sashamilenkovic avatar Jun 10 '24 14:06 sashamilenkovic

Idk For me it's confusing that a toggle button is returning a string instead of a boolean. Why not support both scenarios to make it more universal? It think it can be done without any breaking changes by adding support for the off-value and on-value attributes. Or perhaps with a new attribute. Something like: Multiple Returns array of strings Bool Returns objects of booleans

I wrote a small helper function as a workaround to get from array to object which also works for me but I would prefer a native solution image

Rednas83 avatar Jun 13 '24 08:06 Rednas83

I'll reopen the issue. Perhaps someone else on the team may want to comment.

sashamilenkovic avatar Jun 13 '24 10:06 sashamilenkovic