Table Update Using SC Repeat isn't Working

I have a basic form updating a table. It updates those rows which match multiple dropdown selections (name=“selectBrand”). Here’s the relevant div within the form:

<div class="card-body">
    <div class="form-group">
        <label for="selectBrand" class="form-label">Branding</label>
        <select id="selectBrand" name="selectBrand" class="multi_select_dropdown form-control" dmx-bind:options="serverconnect4.data.getAllBrands" dmx-bind:value="data_detail_product.data.brand.split(',')" optionvalue="id" optiontext="name"
            multiple="true">
        </select>
        <div class="display-container"></div>
    </div>
</div>

On submit, I have set up a repeat based on the selectBrand array.

And here are the update details:

Unfortunately, only the 2nd row of data is being updated, not the 1st. I assume it has something to do with the repeat and its array elements. Any suggestions for what I’m doing wrong would be welcome. Thanks.

After doing some more research it seems the arrays used by server connect repeats are usually created by binding repeat form data.

In my case, my array is created from a comma-separated string. Does anyone know if this could be the reason why my server connect repeat isn’t repeating?

If you are sending a comma separated string to the repeat, you need to use the split formatter for your expression and split by the , character so it becomes an array and the repeat can loop through it.

Thanks for the reply Teodor.

I’m actually already applying the split formatter to the value of my dropdown selections.

<div class="card-body">
    <div class="form-group">
        <label for="selectBrand" class="form-label">Branding</label>
        <select id="selectBrand" name="selectBrand" class="multi_select_dropdown form-control" dmx-bind:options="serverconnect4.data.getAllBrands" dmx-bind:value="data_detail_product.data.brand.split(',')" optionvalue="id" optiontext="name"
        multiple="true">
        </select>
    <div class="display-container"></div>
</div>

The value of the expression ‘data_detail_product.data.brand’ is in the form (1,2,3,…), so I thought applying .split(’,’) would create the correct array.

I was referring to the value you are sending in your server action i.e. the POST variable, used in the repeat expression. That’s where you need to apply the split formatter.

1 Like

That’s exactly what I was after. I created a hidden form field (without the added split formatter)… and used that for my POST variable in the repeat expression. I then applied the split formatter to that.
Cheers for the assistance!