-
-
Notifications
You must be signed in to change notification settings - Fork 683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fields with brackets ([]) #386
Comments
What I did in for example let qs = require('qs')
let buff = ''
form.on('field', (name, value) => {
buff += `${name}=${value}&`
})
form.on('end', () => {
const fields = qs.parse(buff.slice(0, -1))
console.log(fields)
}) something like that? I believe it will work because my package have tests for such nested forms - test/urlencoded.js#L60 |
The problem I see with this, is that there is no standard way of interpreting a non-trivial query string. |
@badeball yea, absolutely. It has workarounds and we shouldn't do something and it's not a job of that package. |
I personally use https://github.com/DylanPiercey/q-set when parsing forms to achieve this effect. |
solved by using q-set to parse form data fields with brackets, after using formidable to parse the requests’ body (node-formidable/formidable#386 (comment)) closes #126.
Going to close, in favor of #545 . |
I'm not sure if this is the appropriate place for this, but I had a need to use form fields with names using brackets: field_name[bracket1][bracket2]. (I guess I really don't NEED this, but it sure makes handling on the server side much better organized.)
I wrote a few lines of code that take the formidable fields and breaks them into JSON objects and values. For instance formidable would pass in the above example as a field named fields.'field_name[bracket1][bracket2]', and I need to have that dealt with in the form fields.field_name.bracket1.bracket2
I don't know whether one would expect to find this code in formidable or some other location of the stack, but I have included below the code snippet I created to make this work:
The text was updated successfully, but these errors were encountered: