Handle checkbox groups (group values)
See original GitHub issueQuestion
I was wondering if there’s a way to handle checkbox groups. Sprig exposes a variable with the same handle as the name of an input, but checkbox groups share a name with an empty array []
. All the values are being sent through ok in the request, but are not combined.
audience[]: 6038
audience[]: 6039
audience[]: 6040
I can’t really make a twig variable with those brackets in the name, so I’m wondering if there’s a way to drop the brackets behind the name and I can get all the values in a comma seperated string. That way I can use the “audience” variable and the comma separated list is easy to |split(',')
so I can use them in an Array to check for checked states.
If I remove the array notation it works, but I only get the last value.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
Checkboxes - The complete HTML5 tutorial
Checkboxes. Using checkboxes is a good option when you want to give your visitors the option to choose several items from a group...
Read more >Automatically check related checkboxes when group ...
Step 1 - Figure out how to store your relationship between Groups and Persons in JavaScript. Something like this should be adequate:
Read more >React Tutorial – How to Work with Multiple Checkboxes
Handling multiple checkboxes in React is completely different from how you use regular HTML checkboxes. So in this article, we'll see how to ......
Read more >Implementing Grouping Checkbox Behavior with Angular ...
The first one is responsible for querying the group checkbox element and interacting with it: The second one is responsible for interacting with ......
Read more >Select Values of Checkbox Group with jQuery - Dot Net Tutorials
In this article, I am going to discuss How to Select Values of the Checkbox Group with jQuery with Examples. Select Values of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@j-greig yep I got it working. Hit me up on Craft discord if you want some more info. I used @bencroker 's example from above and got it working
Check out sprig.pushUrl(url), probably the simplest solution, also explained in this video: https://putyourlightson.com/sprig/videos#7.-pushing-url-updates