#passing extra form data with action

1 messages · Page 1 of 1 (latest)

cinder hazel
#

My case is i try to send data using route action but there are extra data that i want to add to the form data, which is a dynamic data

midnight fog
#

put that in (possibly multiple)

<input type="hidden" name="additional-data" value={data}/>

If it's a large object, you can do

<input type="hidden" name="additional-data" value={JSON.stringify(data)}/>

and parse it in the action

cinder hazel
#

aah, i never thought of using JSON.stringify as value of an input. I was also thinking about using hidden input but i have a problem with making it as an array element,