Update Database value with checkbox group and Array

Hello everyone,

I created a form for changing values in the database via the Bootstrap 4 form generator and I have one field in the database that has a value of e.g. 1,2,4 or 2,4. I did a comma split and the edit form works, it loads good values for each checkbox.

My example is similar to “Dynamically Check Multiple Checkboxes” in the Wappler documentation.

The problem is that when i do Save, only the last value of the checkbox group is entered in the database, so if i selected the first and third checkboxes in the database it will enter only the value 3 (the values of the checkbox fields are first 1, second 2, third 3 and fourth 4) .

The problem is probably a string that i don’t send to the database after clicking save. Please help me how to solve the problem?

Hello, how do you want to store the checkbox values? In a single field or in separate rows?

Hello, i want to store value in one single field.

Then you need to use the join formatter option:

{{$_POST.your_checkbox.join(",", "")}}
2 Likes

i did it in server action in database update but it doesn’t work, now after save, the product_group in the database is empty.

What is the post variable looking like I your server action?
What are the checkbox names on the frontend?

if I understand you correctly …
every checkbox has the same name product_group. also post variable is product_group

Are you using a checkbox group component? If not, please add [] at the end of each checkbox so they return an array.

2 Likes

Great, this works. Thanks a lot.

I think I use checkbox components. I added them by going to the Add “custom multi checkbox form group”. Is that it?
I didn’t have big brackets in the name at the end []. When I added them all it works fine.

Once again, thank you.