How to save toggle value to form data as boolean


I have a settings page and would like to have the toggle state saved into the form data local storage as a boolean instead of ["on"], this would be more useful when retrieving the data.

<form class="list form-store-data" id="settings">
      <label class="toggle toggle-init color-blue" @change="enableLocation">
        <input type="checkbox" name="location" value="on"><i class="toggle-icon"></i>

Is this possible? At the moment I’m having to do this every time I want access to it to get it into a useful form :

var val = settings.location[0]=='on';


Nope, not possible. It works under some kind of convention about form serialization. Checkbox supposed to be an array, because you may have few checkboxes with same name and different values