vendredi 2 septembre 2016

Pug (RIP Jade) form checkboxes - only one value returned regardless how many selected

I have a form written in Pug. I am getting all the correct parameters out of the form's POST, except my checkbox array is a string containing one value - the latest day selected. Each checkbox has a name equaling an array, so the form should be returning all selected checkboxes. However, that is not happening.

Here is the relevant code in the form for the checkbox selection:

form#create-shift-form(action='/shifts/new', method='post')
  div.form-group
    p Select which days this shift should apply:
      div.checkbox-inline
        input.checkbox-input#create-shift-mon(type='checkbox', name='days[]', value='Mon')
        label(for='create-shift-mon') Mon
      div.checkbox-inline
        input.checkbox-input#create-shift-tue(type='checkbox', name='days[]', value='Tue')
        label(for='create-shift-tue') Tue
      div.checkbox-inline
        input.checkbox-input#create-shift-wed(type='checkbox', name='days[]', value='Wed')
        label(for='create-shift-wed') Wed
      div.checkbox-inline
        input.checkbox-input#create-shift-thur(type='checkbox', name='days[]', value='Thur')
        label(for='create-shift-thur') Thur
      div.checkbox-inline
        input.checkbox-input#create-shift-fri(type='checkbox', name='days[]', value='Fri')
        label(for='create-shift-fri') Fri
      div.checkbox-inline
        input.checkbox-input#create-shift-sat(type='checkbox', name='days[]', value='Sat')
        label(for='create-shift-sat') Sat
      div.checkbox-inline
        input.checkbox-input#create-shift-sun(type='checkbox', name='days[]', value='Sun')
        label(for='create-shift-sun') Sun




Aucun commentaire:

Enregistrer un commentaire