With a form including a checkboxes
field and an email
or save
action set up, is there a way to access the individual checkboxes' labels from within the template?
So far, I've only been able to access the id
s and value
s of the checkboxes, like so:
{%- for field in form.fields -%}
{%- set value = form.value(field.name) -%}
{%- if field.type == "checkboxes" -%}
{%- for key in in value|keys -%}
{{- key ~ ": " ~ value[key] ~ "\r\n" -}}
{%- endfor -%}
{%- endif -%}
{%- endfor -%}
To get the default values and labels of a
checkboxes
field, you could try the following:The field definition of the form:
Inside Twig template:
Result in browser: