Checkbox value not set on update form

i have conditional server connect database action steps for add, update, delete, when clicking on the repeated table data row it will open a dynamic modal and show the values to edit and save changes. input text values are set perfectly but the checkbox value is not set accordingly. i have searched in here and tried out almost all the help support solutions but still not working. anyone knows? i only has one checkbox. not the group, database table has IsOnline property and it is boolean. please help. thanks

Can you please explain the issue more detailed please? “Not working” is not really telling us anything about the issue you are haiving.
What is not working and what do you expect to happen?

i have a database table called currencies, it has field like Name, Code, IsOnline, when i generated a table to show the data in the view IsOnline is having value as 1 or 0. so i have done like this {{isOnline ? 'Yes' : 'No'}} to show them as ‘Yes’ or ‘No’, but when i wanted to update record , i have form with two input text for name and code, checkbox for IsOnline, there i could not get the checkbox checked for value 1, none checked for 0. thats my propblem ,

The checkbox only sends a value on form submit when it is checked.
This is how the checkboxes work (not a Wappler limitation):

so if you want to send 0 as a value, use the default formatter in the update/insert steps.

Example: {{$_POST.mycheckbox.default(0)}} and it will send 0 when the checkbox is not checked.

like this? <input type ="hidden" name="isOnline" value="0">

No … did you check what i explained in my last post?

i did that, but my problem is like when i click on the table row to update the record isOnline value is not binding to the checkbox where i have the same form for update and insert as modal.

Sorry, I don’t understand what you mean. Can you please explain your issue in more details?

i got currencies table in database which has 3 fields, Name, Code, IsOnline (boolean). i have displayed this currencies data record in a bootstrap table and i have made the table row is clickable to open a dynamic modal with a form which suppose to reflect the values from Name, Code, IsOnline (as checkbox). in there i have correct Name and Code, but checkbox is not checked when there is value 1 in the database which mean true. first i need to make this work. then when using same form for insert record i have followed a docs and made it success with inserting and updating steps. but update is only update name and code not the checkbox value. for example: if i have true in database, when i update through the form as unchecked, it suppose to be false or 0 right. but thats not happening.

i hope you understand what i have wrote, if not please generally tell me how to use checkbox and value for insert and update action with a same form. how do we bind the value for checkbox when editing or insert.

What i see on your screenshot is wrong.
Your checkbox must have a static value and you should remove the whole dmx-bind:value-"isOnline... part as it is totally wrong.
Your checkbox just needs:

<input class="form-check-input" type="checkbox" id="isOnline" name="isOnline" value="1" dmx-bind:checked="isOnline == 1">

As explained in my previous posts - your checkbox only submits its value when it is checked. If it is not checked it will not send any value to the server action. There you use the default formatter as shown in my previous posts.

To check the checkbox when a database value is 1, use the dynamic checked attribute for it (see code above).

Hi Teodor, this isn’t helped me to solve the edit/update case :frowning:
checkbox is not checked when there is a true value for existing data record when i wanted to edit. As i said above i have click event to bind to the each row of the table, it will open a dynamic modal as you saw in the above screenshot. Hope you got it that i use same form for insert/update.

Well when you open the modal, do you set the active record there? How?
What does your isOnline binding return then - when the record is selected? What value exactly?

Yes i do set the active records, Name and Code is sets correctly since its text value but the boolean value to the checkbox is not set. thats my problem, i have followed the course from him mebeingken and did all the part for using the same form for insert and update. just for text input all works fine, he also showing only for text type inputs. please see the screenshot what i have done when clicked on the table row.

Ok so what does your isOnline binding return? What do you see when you just bind it inside the modal like:

<p>Value returned: {{isOnline}} </p>

i got like this on the screenshot:

The issue is with the expression used for the isOnline. It is just wrong - it must be:

dmx-bind:checked="data_detail_currency.data.isOnline == 1"

If you use the data picker to select it, then it will be generated correctly like that.
Same as your other inputs …

thanks it worked :slight_smile: