form icon indicating copy to clipboard operation
form copied to clipboard

Insert a new value in the middle of an array-like field

Open tmporterSGSI opened this issue 5 years ago • 1 comments

Assume I have the following array-like field

"friends": [ "James", "Julie", "John" ]

and I want to insert a fourth value between "James" and "Julie".

What would be the recommended way to accomplish this without calling pushFieldValue() followed by multiple swapFieldValue() calls?

tmporterSGSI avatar Jul 15 '20 18:07 tmporterSGSI

I suppose one option would be to use setFieldValue()'s callback argument to manually splice the new value into the middle of the array.

tmporterSGSI avatar Jul 15 '20 18:07 tmporterSGSI