You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: