Skip to content Skip to sidebar Skip to footer

Hidden/disabled Fields Disappear From Req.body (express Js Bodyparser)

I have not been able to find the answer to this question. When using NodeJS, Express, and the Express Bodyparser - and the rest of my MEAN stack for that matter - I run into an is

Solution 1:

This has nothing to do with Express. Only successful controls are serialized and sent by the browser when a form is submitted.

The HTML spec defines what makes a control successful.

A successful control is "valid" for submission. Every successful control has its control name paired with its current value as part of the submitted form data set. A successful control must be defined within a FORM element and must have a control name.

However:

  • Controls that are disabled cannot be successful.
  • If a form contains more than one submit button, only the activated submit button is successful.
  • All "on" checkboxes may be successful.
  • For radio buttons that share the same value of the name attribute, only the "on" radio button may be successful.
  • For menus, the control name is provided by a SELECT element and values are provided by OPTION elements. Only selected options may be successful. When no options are selected, the control is not successful and neither the name nor any values are submitted to the server when the form is submitted.
  • The current value of a file select is a list of one or more file names. Upon submission of the form, the contents of each file are submitted with the rest of the form data. The file contents are packaged according to the form's content type.
  • The current value of an object control is determined by the object's implementation.

If a control doesn't have a current value when the form is submitted, user agents are not required to treat it as a successful control.

Furthermore, user agents should not consider the following controls successful:

  • Reset buttons.
  • OBJECT elements whose declare attribute has been set.

Hidden controls and controls that are not rendered because of style sheet settings may still be successful.

Your problem is actually Angular. Apparently, it does not set the value of hidden inputs.

Post a Comment for "Hidden/disabled Fields Disappear From Req.body (express Js Bodyparser)"