Multi reference field only updating when posting more than one item

Wappler Version: 6.3.2 Stable and Beta
Operating System: Windows 11
Server Model: Node / Capacitor
Database Type: Postgres
Hosting Type: Docker / DO

I have a Contact table with a Label multi reference field.

image

Expected behavior

When selecting one Label and clicking apply the Server Connect should add the one Label to the Contact_Label junction table.

image

Actual behavior

For some strange reason, the Label(s) are only added when I submit more than one Label. With one label the Contacts Server Connect shows a 200 response, but when checking the junction table the record is not added.

If I select more than one Label, then both labels are added to the junction table correctly.

The same issue happens when attempting to remove the labels.

How to reproduce

  1. Create a Contact table.
  2. Create a Label table.
  3. Create a multi reference field on the Contact table to the Label table.
  4. Create an update API that will modify the Contact table and add the Labels to the $_POST.Label field on the Contact table.

Here’s the form code.

<form is="dmx-serverconnect-form" method="post" id="ContactLabelUpdater" action="https://dev.brightyard.co/api/v1/contacts" site="brightyard-server-v3" credentials="true" dmx-on:success="ContactsFlow.run({label: query.l, search: query.s, type: query.t})">
    <ul class="link-list-opt no-bdr ps-2 pe-2">
         <li dmx-repeat:labels="GetContactLabel.data.contactlabels">
               <div class="dropdown-item custom-control custom-checkbox">
                   <input type="checkbox" class="custom-control-input nk-dt-item-check" name="Label" dmx-bind:id="LabelChecked-{{$index}}" dmx-bind:checked="data_detail_contact.data.FormattedLabels.contains(FormattedName)" dmx-bind:value="LabelId">
                  <label class="custom-control-label" dmx-bind:for="LabelChecked-{{$index}}">{{FormattedName}}</label>
              </div>
         </li>
         <li class="divider"></li>
         <li><button class="btn btn-outline-primary w-100" type="submit">Apply</button></li>
    </ul>
    <input type="hidden" id="ContactLabelUpdaterContactId" name="ContactId" dmx-bind:value="data_detail_contact.data.ContactId">
</form>

Bump.

Is in the Server Action the input $_POST.Label set to Multiple?

Negative. Should I set it?

image

I set it to see if it made a difference, but the outcome is still the same. If I try to select only one item, then it is not added. I have to select multiple items for it to be successful.

Hey Keith,

I just read a few times your threat and I’m confused…
I suppose your input LabelChecked is an array… Correct?
I saw your payload a few posts behind and didn’t like it…
Can you update a) only 1 label and b) more labels and check the payload? Is it an array in both cases?

*Wouldn’t that be easier with a multi-checkbox group? (just saying…)

Hey Tasos!

I believe this is correct. Although it’s sent as separate form-data. I’m not knowledgeable on how the separate form-data fields become an array though.
image

Whether I send only one label or more than one, the Form Data format is the same.

I’m not understanding. The user is able to select multiple labels.


I could be wrong, but I think this may have something to do with how Wappler handles POST data for multirefence fields.

As a different solution, I created another API that allows me to update the junction table directly. The Label checkboxes POST correctly with it. Which I hope provides more relevance to my hypothesis that the bug is related to the POST multireference processing.

1 Like