1

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.

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

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:

<input type="checkbox" name="fields[gistDraft]" value="1" {% if entry.gistDraft %} checked="checked"{% endif %} />

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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.