You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I have a form where I use Precognition with Alpine, and on submit, I am trying to iterate the properties of the Precognition form object to create a FormData to submit. Works great except that arrays (multi-select, checkbox group, etc) get added as strings, not arrays. I have done some research on Javascript Proxy objects and I don't really understand them and from what I read, there is no way to get the actual value out of them? But when the validate function submits an array field it submits it as an array.
let submitData = new FormData()
for(let key of touchfields) {
submitData.set(key, form[key])
}
tags comes out as "horror,girls,screaming" and characters comes out as "1,2,3" instead of as the expected arrays. How can I get them as arrays? Can I? I'd rather not have to explode them on the back end if I don't have to.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I have a form where I use Precognition with Alpine, and on submit, I am trying to iterate the properties of the Precognition form object to create a FormData to submit. Works great except that arrays (multi-select, checkbox group, etc) get added as strings, not arrays. I have done some research on Javascript Proxy objects and I don't really understand them and from what I read, there is no way to get the actual value out of them? But when the validate function submits an array field it submits it as an array.
My form object:
And in the submit handler:
tags comes out as "horror,girls,screaming" and characters comes out as "1,2,3" instead of as the expected arrays. How can I get them as arrays? Can I? I'd rather not have to explode them on the back end if I don't have to.
Thank you for your time.
Beta Was this translation helpful? Give feedback.
All reactions