This PR adds a new formDataArrayFormat option to Link and router.visit that duplicates the logic of queryStringArrayFormat, but for formData arrays serialization.
Rationale
Currently, multipart form data arrays are always serialized using indices:
Rails (or more precisely Rack) parses this as hashes with keys '0' and '1'. To support scenarios like a file input with the multiple attribute, we need to allow the tweaking of this behavior.
This PR introduces the formDataArrayFormat option to router.visit. With this option set to 'brackets', we serialize the keys in the format required by Rack/Rails:
I have set formDataArrayFormat to 'indices' by default to preserve the current behavior. We might want to synchronize formDataArrayFormat and queryStringArrayFormat values at some point (or even introduce more general option), but this could be a breaking change.
This PR adds a new
formDataArrayFormat
option toLink
androuter.visit
that duplicates the logic ofqueryStringArrayFormat
, but for formData arrays serialization.Rationale
Currently, multipart form data arrays are always serialized using indices:
Rails (or more precisely Rack) parses this as hashes with keys
'0'
and'1'
. To support scenarios like a file input with themultiple
attribute, we need to allow the tweaking of this behavior.This PR introduces the
formDataArrayFormat
option torouter.visit
. With this option set to'brackets'
, we serialize the keys in the format required by Rack/Rails:Notes
I have set
formDataArrayFormat
to'indices'
by default to preserve the current behavior. We might want to synchronizeformDataArrayFormat
andqueryStringArrayFormat
values at some point (or even introduce more general option), but this could be a breaking change.