Dynamic pre-selection of CS Forms Checklist Option

Hi Themeco Team,

I am coming back to my older support request but a more specific example.

Let’s say we have an ACF custom taxonomy Month with all 12 months added as the taxonomy items. What we need is on page load to grab the current date and to define the current month. Then with respective TWIG Template we compare if it is true or false for each ‘Month’ taxonomy item. Potentially that could allow us to pre-populate ‘true’ or ‘false’ value inside Selected option while in Breakout Mode inside CS Forms Checklist Option. In the end, we need just the current month taxonomy item to be pre-selected on page load and maybe also on Clear Filter button flush. But even though the TWIG script works in a text element, it doesn’t work in the ‘Selected’ option in the form. No matter if it is ‘true’ or ‘false’ that item is always pre-selected as it is in ‘true’ state if TWIG template is linked.


Here instead of false we link respective TWIG template.

And here is the TWIG template script for January only:

{% set month = global.date|date('m') %}
{% if month == 01 %}
      true
{% else %}
      false
{% endif %}

Ideally we need another TWIG script that will check each taxonomy item in the Loop dynamically and define true or false for each, no matter what month it is but I am not sure how to debug it correctly when the TWIG Template is linked already to the Selected option. It is definitely not the best idea to add items for each month by hand, then create a TWIG script for each month separately, and link them up. I just put it as a starting point.

Please let me know if I am thinking in the wrong direction. Maybe there is a simpler way to accomplish it. Or maybe it is not possible yet without custom coding.