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

Problems with numeric nested form element names #40

Closed
lucaswxp opened this issue Aug 16, 2014 · 2 comments
Closed

Problems with numeric nested form element names #40

lucaswxp opened this issue Aug 16, 2014 · 2 comments
Labels

Comments

@lucaswxp
Copy link

Heys guys!

I have a form that looks more or less like this:

<input type="checkbox" name="checklist[1]" value="1" />
<input type="checkbox" name="checklist[2]" value="1" />
<input type="checkbox" name="checklist[3]" value="1" />

I was expecting that request.body.checklist looked like this (after all checkboxes were checked, of course):

{
'1': '1',
'2': '1',
'3': '1'
}

But what I got was a array, without the indexes I need to associate the result:

['1', '1', '1']

This seems like a bug to me. I would expect the array only for zero-based indexes.

@jonathanong
Copy link
Member

belongs here: https://github.com/hapijs/qs

@dougwilson
Copy link
Contributor

another option is to just not use extended at all, because it's dumb :) also, in raw HTML itself, if all your checkboxes are related, you're supposed to just name them all the same thing: 'checklist'. they come through in the order they are in the DOM. extended: false would then parse it as ['1', '1', '1'], where they are the order in the DOM.

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

No branches or pull requests

3 participants