expressjs / body-parser

Node.js body parsing middleware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failure to Parse Bootstrap List-Group

buzzbonner opened this issue · comments

I've working with an existing application that uses body-parser to package form data into a request object. This parses all input form data values, including arrays for Select objects.

My problem is that these Select objects need to be replaced by Bootstrap List-Group objects providing multi-select of checkbox lists. However, I'm unable to get these arrays to appear in the parsed request object.

Would this be supported? If not, if there a workaround?

Cheers

Buzz

Hi @buzzbonner sorry, I'm unfamiliar with that Select objects, Bootstrap List-Group objects, etc. are. May it would help if you could show what it looks like to this module? i.e. which parser of the four are you using (json, urlencoded, etc.)? what does the http body content look like, and what are you expecting the resulting req.body to look like from that body?

Hi, so I'm using urlencoded...

<ul class="list-group">
        <% Object.keys(config.dept).forEach(item => { %>
            <li>
                <input type="checkbox" value = <%=item%>  id = <%=item%> />
                <label class="list-group-item no-case" for = <%=item%> >  <%=config.dept[item]%></label>
	</li>
        <% }) %>
    </ul>

From the script above I am successfully displaying a list of departments. However, when selecting these do not appear in the Form Body request. I suspect body-parser is not reading the UL List-Group as it's not an Input?

  • Cras justo odio
  • List-Group documentation shows the active attribute would be set. So how can I get a list of active items into the req.body?

    Hm. There is a lot going on there, so not sure. Ideally if you would be able to show the actual http body going into the module that would be awesome, otherwise with something as partial as the above, I would need some complete code that actually runs and I can get it up and running and see the same thing you're seeing so I can debug it and determine the issue at hand 👍

    Closing since I never heard back.