How to access and use the array of items in Sortable-Input

Web Tips Q & ACategory: Krajee Yii2 ExtensionsHow to access and use the array of items in Sortable-Input
f.carrasco.v asked 1 year ago

Hello,
I would like to know how can I access and use the keys in the items array, for use in a batchInsert?
Given the next scenario: I have a tableA like this
id | tableB_id | tableC_id
Where id_tableA is auto incremental, and both tableB_id and tableC_id are FK.
I need to insert in tableA multiple id from tableB which where selected from a connected Sortable, and the same id from tableC, wich was selected from a dropdown, resulting in something like this:

id | tableB_id | tableC_id
--------------------------
1 | 2 | 4
2 | 3 | 4
3 | 5 | 4
. | . | 4
n | x | 4

There’s no problem when I select only 1 item and submit the form, but when I select two or more I can’t submit because obviously the tableB_id can accept only integer.
 

f.carrasco.v replied 1 year ago

In a few words, how do I access the hidden input with the array of Ids to explode it for use it in a batchIsert?
Thank you!

Login or register to contribute or comment.

Login   Register