Sprout Forms - Notification Based on Checkbox Value I'm using Sprout Forms 3.8.0.2 and Craft CMS 3.4.5. My client wants the email notification to go to different email addresses based on whether or not a form checkbox is checked. My plan is to create a new notification for each checkbox value, with the checkbox logic in a custom rule. I've read through the documentation, but I can't figure out how to write the code that checks whether a checkbox is checked. I think it's something like
{ checkBoxFieldHandle == 'value' } or { checkBoxFieldHandle.valueBeingChecked.selected } but neither of those are sending any notifications after a test message. Any advice on how to do this? Thank you!
You're on the right track.

The first thing to note is that the Send Rule field does support shorthand syntax like in your question, however, if you are using compound logic, you will want to use the full object syntax for that logic.

So, instead of (with no reference to object. and single curly braces):

{ checkBoxFieldHandle == 'value' }


You'll want to use the full object syntax to get the expression to evaluate:

{{ object.checkBoxFieldHandle == 'value' }}




The next thing to note is that the checkbox field is a multi-select input, meaning more than one value can be selected. This could be present additional logic challenges for what you are trying to do but assuming you have a checkboxes field with a single checkbox or an opt-in field the logic is more predictable.

Checkboxes are submitted as arrays, so you'll need to make sure you are targeting the correct node in the array. In the case of a single checkbox, we know the first checkbox will be index 0 in the array. Once we have the target checkbox, we can see if it's selected by checking the selected attribute:

{{ object.checkboxFieldHandle.getOptions()[0].selected == true }}


And we can update the same statement to check for false if we want to only send if the checkbox is unchecked:

{{ object.checkboxFieldHandle.getOptions()[0].selected == false }}