<p>The Lightswitch field is a simple boolean/tinyint column, with a 0/1 value. For this to work, you want to do something like this:</p>

<pre><code>&lt;input type="checkbox" name="fields[gistDraft]" value="1" {% if entry.gistDraft %} checked="checked"{% endif %} /&gt;
</code></pre>

<p>If you are sending the value some other way than a checkbox (the lightswitch field is a hidden checkbox), make sure that gistDraft has a value of 0 (off) or 1 (on).</p>

CC BY-SA 3.0
2014-09-21T10:34:09.560Z
2014-09-21T14:27:24.573Z
2014-09-21T14:27:24.573Z
Fred Carlsen
<p>I have the following buttons on my frontend entry from (user editing one of their entries). The idea is to turn the lightswitch "on" (green) when entry is being marked as draft and "off" when submitted for review. The turning it "on" part seems to work. I just cannot seem to control its "off" state.</p>

<pre><code>   &lt;div class="col-md-6"&gt;
        &lt;button class="btn btn-primary btn-lg btn-block " style="margin:10px 15px 0 0;" type="submit"  name="fields[gistDraft]" value="true"&gt;Save as Draft&lt;/button&gt;
    &lt;/div&gt;  
   &lt;div class="col-md-6"&gt;
          &lt;button class="btn btn-success  btn-lg btn-block " style="margin:10px 15px 0 0;" type="submit"    name="fields[gistDraft]" value="false"&gt;Save &amp;amp; Submit for Review&lt;/button&gt;
        &lt;/form&gt;
    &lt;/div&gt;  
</code></pre>

<form><entry><lightswitch>
Populate Lightswitch field from Frontend Entry Form
# Populate Lightswitch field from Frontend Entry Form

(Asked by: username_0 on 2014-09-19)

I have the following buttons on my frontend entry from (user editing one of their entries). The idea is to turn the lightswitch "on" (green) when entry is being marked as draft and "off" when submitted for review. The turning it "on" part seems to work. I just cannot seem to control its "off" state.
   
        Save as Draft
      
   
          Save & Submit for Review

**Tags:** form, entry, lightswitch

---

## 1 answers

### Answer by username_1 on 2014-09-21. Score: 3 | Accepted answer

The Lightswitch field is a simple boolean/tinyint column, with a 0/1 value. For this to work, you want to do something like this:


If you are sending the value some other way than a checkbox (the lightswitch field is a hidden checkbox), make sure that gistDraft has a value of 0 (off) or 1 (on).


---

