vendredi 5 août 2016

Change checked value of bootstrap-checkbox plugin, when submitting form

I am using bootstrap-checkbox within a html form as follows:

<form action= ...>

// some inputs...

<input id="mySwitch" class="switch" type="checkbox" name="mySwitch"
data-off-active-cls="btn-warning"
data-on-active-cls="btn-primary"
data-group-cls="btn-group-sm"
value="1">

//more inputs...

</form>

My problem is that when I am submitting the form, the default value for checkbox plugin is "on" and I want to change it to something else, e.g "1"

I tried to add a value="1" property to the input element but I still receive "on" as a checked value at the server.

//HTTP request output    

array:19 [▼
"_token" => "192q78C3xGUorq0mFQMk7g0VSBcojjvt9ikkWLE4"
  ...
  "mySwitch" => "on" // <-- I want this to be 1
  ...
]

Any help appreciated, thank you




Aucun commentaire:

Enregistrer un commentaire