Tutorial or Doc Needed -- How To Generate an Update form that shows Multiple Choice Checkboxes

Wappler Docs, Tutorials, Videos refer to “Update Form”

I will PayPal to see one complete Wappler “How To Create an Update Form that also handles Multiple Choice Inputs such as Checkbox Groups and Multiple-Choice Dropdown lists.”

Yes, I know how to make a form page populate with a given record and DMX bind values from a Get query. Or I can re-use the Insert Form itself with a filtered query for the key id in that record.

But I have several fields that store multiple choice checkbox values as comma separated text fields. There are 7 or 8 text values per Checkbox group that can be chosen and stored as “value,value1,value4,value8” etc I know I have to transform the Get field value array into its separate string values so that I can add a “selected” class to each checkbox with an "IF $value equals … " comparison.

I don’t know if I should build an API query to Get this record and individually pull each checkbox value out then or do it server side – questions like that …

I want to see those checkbox groups in the Update Form displayed selected or unselected as their individual values are found or not found in the existing field array. I know the steps in a php loop to generate this but I know that a complete Wappler Tutorial on Creating an Update Form would make this all logical and sleeker.

As I say, I will PayPal for this.

This you get any help on this yet?

THE OTHER WAY

Now if you are planning on having the checkboxes do insert and update at in the same logic, this will require a few hack.

  1. The key here is Your API action will have be just a update step to kill two birds with one stone instead of doing a separate insert and update.

  2. You will have to have each fields in your database for each separate checkbox (This is because we want to simplify things by just using true or false at the checkbox level on the front vs sending the actual displayed value users are checking the box for. For example (stolz) will only send back a value of true if checked or false if not checked. Then in API action on the backend we will write a condition to check if true returns from the form POST then update the database field to (stolz) or if false update field to “” or whatever make sense to you). This is idea here for having each checkbox values getting their own fields in the database table.

  3. On the form you are going to have a checkbox form group for each checkbox value being displayed, so (stolz is going to have it own checkbox form group), (dankbar is going to have it own checkbox form group) so fourth and so on . Within that checkbox form group you will have the checkbox input itself and two other hidden text input.

Here are the steps for setting up Checkbox Group and Checkbox Control

In the CHECBOX GROUP PROPERTIES
for the “value” bind the server connect data thats querying the table from the database and make sure to add .split(’,’) at the end. So, for example if your server connect name is checkedboxdata it will be something like checkedboxdata.data.somefieldname.split(’,’). Doing this will allow us to populate the checkbox input.

Checkbox Control

Now, give the checkbox input “ID” a name like stolz_checkbox and a Static Value of true.

Next we need to add two text input under the checkbox input and make the “Type” hidden
you can give one of the text input a “ID” name of inpt_whenchecked and “Name” stolz_value. This is the hidden input that we will send back on form submit for this specific checkbox form group thats targeting the stolz checkbox input and its label. We will also give this text input a DYNAMIC ATTRIBUTES value and bind it with the Checkbox input value when checked. So, the DYNAMIC ATTRIBUTE value should look like this stolz_checkbox.checked.

Next we will do the same for the second text input. We will give it a "ID’ name of inpt_stolz_checkbox_returnedvalue, and a Type of hidden. We will also give it a DYNAMIC ATTRIBUTES value bind to checkedboxdata.data.somefieldname, do not add .split(’,’).

Next go back to the checkbox input and add a DYNAMIC ATTRIBUTES Checked and for the value pick the value coming from the text input “ID” name inpt_stolz_checkbox_returnedvalue. The Checked value should look like this: inpt_stolz_checkbox_returnedvalue==‘stolz’. doing this will allow the checkbox to be checked when the condition is true.

Do this for all the checkbox groups that you want to send update for.

Backend

As for the $_POST values, set up set values that point to each $_POST and use Conditional>> Contains>> Then, this condition checks for the value true or false upon form submitted and base on which is sent it will send the given info to your database. Do the condition like so:

If This is not so clear feel free to message me directly and I can walk you through the steps.