Group Checkbox Insert

I have a group checkbox input that is failing to insert into the database. I have followed the instructions for Wappler version 3 tutorial. However, though the record is added to the database, it does not add all the items checked in the group. It only adds the last checked item. It seems that I’ve missed something that should gather the array. Should I put brackets on the name=“school_type” of each checkbox?

Any suggestions where I can look?

Below is the group checkbox code :

<div class="form-group col-md-6 col-lg-4 col-xl-4" is="dmx-checkbox-group" id="school_type_group" dmx-bind:value="school_type_group.value[0].$value.split(',')">

<legend class="pb-2" style="font-size: 16px;">School Type</legend>

<!-- group checkboxes -->

<input id="checkbox1" type="checkbox" name="school_type" value="Boarding Day">
<label class="form-check-label ml-1 mr-5" for="input3">Boarding</label>

<input id="checkbox3" type="checkbox" name="school_type" value="Day">
<label class="form-check-label ml-1 mr-5" for="input3">Day</label>

<input id="checkbox4" type="checkbox" name="school_type" value="Night">
<label class="form-check-label ml-1" for="input3">Night</label>

<!-- group checkboxes -->

</div>
name="update_images_checkbox[]"

this is what all the names on mine are and it collects an array never tried without them

How does the following code work with the array? Will it place the comma between each item in the array?

dmx-bind:value="school_type_group.value[0].$value.split(’,’)"

I believe it creates a non comma separated array in my action I loop the array and insert them into the database using the $value in the repeat

So each checkbox should have the
name= "school_type[ ]"
to make it collect the values inside an array?

Yes that should collect all the checked values and create the array for use in your server action I haven’t tried without them having brackets

I’ll give it a go and see what happens. Thanks!

After adding the brackets to each name=“school_type” inside the three checkboxes, I get the following error: “message”: "Array to string conversion"

Where do you get this may seem like a odd thing to ask but did you re import the form inputs into the server action?

I thought I could use this tutorial to see if I could get the multiple selected checkbox data to load into the database as arrays. However, I am not very good with arrays. Ha!

However, this works great for updating the data etc. But I cannot figure out how to get the checked items into an array. I guess I need another cup of coffee to clear the fog!

How would you setup radio buttons or checkboxes to gather the data of items checked into an array?