Despite my best efforts I'm stuck on getting the array keys for form elements submitted to NodeJS and Express and handlebars.
My form elements look like this:
{{#each block}}
<input type='text' name='block_payout[{{id}}]' />
{{/each}
This results in the following markup in the browser:
<input type='text' name='block_payout[14]' />
<input type='text' name='block_payout[15]' />
<input type='text' name='block_payout[16]' />
In PHP this would result in an array as an element of the $_POST array:
$_POST [
block_payout [
14 => value1
15 => value2
16 => value3
]
]
However, the req.body property in Node/Express removes these keys and creates an indexed array:
req.body [
block_payout [
0 => value1
1 => value2
2 => value3
]
]
Since I want to use the key to tie the submitted values to something else this is a big problem for me. Does anyone know how I can get the submitted form data with the correct keys??