Convert comma separated values to array or object on backend

Stuck on (basic?) problem.

First of all : I have this working as intending using a datastore component, but it is too slow on the client side.

Working method:
Table with checkboxes that push selected record ids to the datastore.
Separate custom select outside the multi record form repeater.
I post the datastore and custom select variable to the backend.
The repeat sets the variable in the right column for all ids in the record.
So basically passing an array and a separate variable

Even if I limit the datastore to only take in the record ids it is slow. Say if I push 500 rows to the datastore it takes a couple of seconds before the data is in place. Posting to the backend and processing the data is fast.

Using the checkboxes to push ids to an array is much faster, but I am struggling to post them properly to the backend repeater.
I dont see the point of using the multi record form here since i can probably just push all the ids that needs processing directly to the backend

Any guidance ?
The input is set to value : array.items
How can I convert this to an array or object on the backend to pass it to the repeat

Or give me a better method if any :wink:

Made it work on the frontend using a repeater on the array and referencing $value

Edit: Only processeses the first 282 rows, but I guess I will limit the amount to be processed anyway.

Not completely following what you are trying to do… but here are some pointers on multiple checkbox handling:

  1. Use [] to submit an array of selected checkboxes to the server action via POST. Set the name of all checkboxes in repeat to be say checkboxID[].
  2. If you can’t do that (for any reason), and are stuck with sending CSV values to server action, you can use the split function to convert that to an array. Something like allCheckboxes.split(",") in the repeat param. Then use $value to get the current checkbox value inside the repeat.
  3. If you are handy with SQL & custom queries, and you requirement is to do something similar to all the selected IDs, you can write a single query to update your table in the DB, instead of having to use repeat. But, mind you, this will be a bit complex and it should fit your requirement. I cannot give an example of this because I don’t have the structure.

Hi Sid,

This was helpfull. I have a select field where users can select multiple items. The variable i gave the name roles []

In the API i just user the repeat function on the array field and insert the values with a database insert.

image

It works like a charm.

Cheers, Harm

Update:

It works even without '' because selecting multiple in the select field is enough to make it an array.