On form POST, only the first column of form data get submitted. The second column (category and priority) are undefined. If I move the submit button to the second column the exact opposite happens. Then if I rearrange the form to have only one column, all of the form values get submitted(temp work around). How can I implement this form with two columns and have the entire form submitted?
Console log output:
from CREATE ISSUE CONTROLLER
req.body.title: New bug report
req.body.description: New bug report
req.body.priority: undefined
req.body.category: undefined
The form code (.pug):
#newissue.tab-pane.fade(role="tabpanel" aria-labelledby="newissue-tab")
.row
.col-md-6.offset-md-2.new-issue-form
form(method="POST" action="/newissue")
.form-group
label(for="newIssueTitle") Title
input#newIssueTitle.form-control(type="text" placeholder="Issue title ..." name='title' required='true')
.form-group
label(for="newIssueDescription") Description
textarea#newIssueDescription.form-control(rows="10" placeholder="description" name='description' required='true')
div
input#filepond(type="file" name="filepond" data-max-files="10" multiple="")
button.btn.btn-success(type="submit") Create New Issue
.col-md-2.new-issue-form.input-group.mb-3
.form-group.mb-3
label(for="category") Category
select#category.form-control(type='select', placeholder='Category ...' name='category' required='true')
for category in categories
option(value=category._id) #{category.name}
.form-group.mb-3
label(for="priority") Priority
select#priority.form-control(type='select', placeholder='Priority ...' name='priority' required='true')
option(selected="") Priority...
each pri in priorities_list
option(value=pri._id) #{pri.name}
else
li No priorites
The way the Pug is written, none of your second column is inside the form
element. All elements of a form have to be inside of the form
element in order to be submitted.
Try moving the form
element to contain the entire .row
:
#newissue.tab-pane.fade(role="tabpanel" aria-labelledby="newissue-tab")
form(method="POST" action="/newissue")
.row
.col-md-6.offset-md-2.new-issue-form
.form-group
label(for="newIssueTitle") Title
input#newIssueTitle.form-control(type="text" placeholder="Issue title ..." name='title' required='true')
.form-group
label(for="newIssueDescription") Description
textarea#newIssueDescription.form-control(rows="10" placeholder="description" name='description' required='true')
div
input#filepond(type="file" name="filepond" data-max-files="10" multiple="")
button.btn.btn-success(type="submit") Create New Issue
.col-md-2.new-issue-form.input-group.mb-3
.form-group.mb-3
label(for="category") Category
select#category.form-control(type='select', placeholder='Category ...' name='category' required='true')
for category in categories
option(value=category._id) #{category.name}
.form-group.mb-3
label(for="priority") Priority
select#priority.form-control(type='select', placeholder='Priority ...' name='priority' required='true')
option(selected="") Priority...
each pri in priorities_list
option(value=pri._id) #{pri.name}
else
li No priorites