Hi All,
I’m working on a form (~15 questions + a set of ~10 checkboxes). This has led me to wonder what’s the best way (organizationally and performance-wise) to store checkbox data, assuming the checked items will be dynamically displayed on a different page (if an item is NOT checked, it should NOT be displayed).
Here’s an example form to illustrate:
I wonder if the checkbox data should be:
(a)
stored in a field as a ‘List of texts’ with only the checked items added
(b)
stored in a field as a ‘List of yes / nos’
(c)
stored in individual ‘yes /no’ fields (one field per checkbox item)
(d)
stored in its own data type, with that data type then stored in a field of the ‘parent’ data type
At this point, I’m guessing (c)
and/or (d)
are the best options. But I would love to hear from others how they’d handle this situation.
To test this, I created a Data Type with all options above:
NOTE: when testing each scenario, I hid the fields I wasn’t using to make it easier to read
And here’s the Option (d)
‘child’ data type:
OK, on to the ‘Submit’ button’s workflow.
Option (a)
- Checkbox data stored in a field as a ‘List of texts’ with only the checked items added:
In the workflow, I added each checkbox value individually, but changed the ‘Boolean Formatting’ to the type of activity (i.e. ‘reading’) for ‘yes’ and nothing (or an empty string) for ‘no’. Here’s a workflow image:
The results were funky. Specifically, if you don’t check all options, you have the unchecked items represented by empty strings in your list:
Question: Is there a way to add selected items only to the field’s list? And would this be a reasonable way to go?
Option (b)
- Checkbox data stored in a field as a ‘List of yes / nos’.
Here’s my workflow:
This clearly did not work, since I only got 2 of the 4 checkbox values entered into a database row:
I’m obviously doing something wrong here. But I’m not sure this would be a good option even if I got it to work, because it likely would be difficult to deal lists such as [yes, no, yes, no] … not easy to track which value is associated with what checkbox.
Option (c)
- Checkbox data stored in individual ‘yes /no’ fields (one field per checkbox item)
Here’s the workflow:
And here’s the results:
This seems nice and organized. Since I’m just learning Bubble, I’m not sure if this method would get overwhelming if you had, say, 50-100 checkboxes?
Option (d)
- Checkbox data stored in its own data type, with that data type stored in a field
Here’s the workflow (2 steps):
- Step 1 - create new ‘thing’ storing the four yes/no values
- Step 2 - store step 1’s ‘thing’ in data type that also includes name & age fields
The results also seem to work, and is perhaps easier to work with than Option(c)
with larger sets of checkboxes, although I’m not yet sure. The results in 2 pics:
The above pic shows a unique identifier pointing to the ‘yes’ and/or ‘no’ entries in another Data Type:
So, in my non-expert opinion, I think options C and D can work, with option D perhaps better for very large sets of checkboxes.
Could some people who have experience with this chime in? What is your opinion on best way to handle this scenario?
Hopefully this thread will help noobs like me in the future.
Thanks,
-Tim