How do I check if a checkbox is checked?
I have a custom checkbox field in my template containing two checkboxes.
How do I check which checkbox is checked in my template?
Comments are currently closed for this discussion. You can start a new one.
Log in to Harmony
I have a custom checkbox field in my template containing two checkboxes.
How do I check which checkbox is checked in my template?
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Steve Smith on 18 Aug, 2010 02:44 PM
The easiest way is {% if item.data.checkbox_name != blank %}
3 Posted by Thomas Watson on 18 Aug, 2010 04:20 PM
Don't I then only get the checkbox field "wrapper"?
As far as I understand the system, a checkbox field is actually not a single checkbox but a group of checkboxes. The only identifier I give a checkbox is its label (the text shown to the right of the checkbox) - i.e. the text that is shown to the user
In my case (see attached screenshot) I have a checkbox field with more than one checkbox and I want to verify if a specific one of them is checked.
4 Posted by Thomas Watson on 31 Aug, 2010 12:00 PM
Anybody?
5 Posted by John Nunemaker on 02 Sep, 2010 02:11 AM
Gotcha. Misunderstood the first time. Just did some small tests. It appears there isn't an easy way right now. I'm looking at adding something to help you out.
6 Posted by John Nunemaker on 02 Sep, 2010 03:09 AM
Ok, I put together an include filter.
http://docs.harmonyapp.com/harmony-templates/filters/array-filters/...
The docs show how to use it in an if statement. Unfortunately, filters cannot be used in if statements so you have to assign the result to a variable and then use the variable in an if statement. If you follow the link above, the example should explain things.
Hope this helps.
John Nunemaker closed this discussion on 02 Sep, 2010 03:09 AM.