Drupal 10: Using A Boolean Field In A Twig Template To Control Markup

Assuming your boolean field is called field_page_check then the template should have this if statement in it.

{% if content.field_page_check is not empty and content.field_page_check['#items'].value == '1' %}
<p>This will be displayed if the check box is set to "true".</p>
{% endif %}

 

Add new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
1 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.