In this tutorial we will show you how to check multiple checkboxes, based on a database value. This is useful if you are using an update record form, or some details page which show multiple checkboxes that rely on a dynamic value.
In our case this is our update record page, which shows reservations info:
You can edit or remove the dummy checkboxes added in the group. Also you can add more.
In order to edit a checkbox, just select it in the App Structure then add a value for it:
What is the proper way to update the database with this info? I have a form with 8 categories that you can check. I named all of the names for all 8 checkboxes as “category”. When the update occurs it updates 1 at a time so only the highest number is saved.
Basically, if I select boxes 1,3 and 5, it will update the database to 1, then 3, then 5 – so only the 5 is saved. How do I get it to enter “1,3,5” into the database field.
Can you send a screenshot of your server action with the $_POST Global shown as well as a second screenshot with your database insert/update shown.
Basically you are going to POST an array of all the values checked from your checkbox group and then you are going to use a formatter of join to send the comma separated list of values into your database.
Your database field type will also need to be a varchar or something so it can take integers and commas as well.