Skip to content
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

Bug with form arrays and bodyParser #5

Closed
silkcom opened this issue Mar 16, 2014 · 2 comments
Closed

Bug with form arrays and bodyParser #5

silkcom opened this issue Mar 16, 2014 · 2 comments

Comments

@silkcom
Copy link

silkcom commented Mar 16, 2014

senchalabs/connect#1025 -- I put this error there first, but was directed here.

I just found a wierd bug when using bodyParser and form arrays.

I have a form elements with names of
items[1]
items[2]
etc.

When these submit, I get an array from bodyParser that looks like:
{ items: ['on', 'on'] }

rather than:
{ items: { 1: 'on', 2: 'on' } }

If instead I change the form to have names of
items[id_1]
items[id_2]

it works great (except now I need to replace id_)

dougwilson over on the other form brings up a good point against treating it like an array, but honestly just dropping the values on the floor is worse than the possible problem. Making it always an object if the id's are specified seems like the only answer. That way it works the same as PHP does, which makes a lot of sense.

@silkcom
Copy link
Author

silkcom commented Mar 16, 2014

tj/node-querystring#77 :) seems to be where the arguement is

@silkcom silkcom closed this as completed Mar 16, 2014
@dougwilson
Copy link
Contributor

Hi @silkcom I finally found something that looked the most like you wait, I think: tj/node-querystring#62

As far as I can tell, that PR makes qs just return objects, even with numeric indices.

@expressjs expressjs locked and limited conversation to collaborators Jul 20, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants