0

I have a frontend form that allows users to toggle a lightswitch field. I discovered that the entry does not update correctly when passing true or false with the request, despite my frontend receiving such values from Craft. So instead I have to ensure that each true and false value is converted to 1 or 0 which then lets the entry update correctly.

It isn't the end of the world, and I have things working now, but I'm curious if Craft should be accepting true and false and I'm just doing something wrong?

Otherwise it'd kind of be nice if it could be consistent: Craft either puts out true/false and accepts true/false, or puts out 1/0 and accepts 1/0

  • 2
    If you do <input type="hidden" name="lightswitch" value="true"/>, this will give a string type "true" or "false". And in backend, "true":string != true:boolean.. So it doesn't recognise. – Parry Huang Jul 25 at 6:51

Your Answer

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

Browse other questions tagged or ask your own question.