getgrav / grav-plugin-email

Grav Email Plugin
http://getgrav.org
MIT License
37 stars 29 forks source link

How to get checkboxes options labels in email body? #43

Closed maximelebreton closed 1 year ago

maximelebreton commented 7 years ago

Hi all!

I want to get the checked checkboxes labels in the body object (example: Captation vidéo label), but there is only the name and value in the form fields object, so the message body is like this:

Message body:

Object:
 {"object-captation_video":"captation_video"}

contact.md:

            name: object
            type: checkboxes
            options:
                enregistrement: enregistrement
                mixage: Mixage label
                travaux_d_electronique: Travaux d'électronique label
                captation_video: Captation vidéo label

default/data.html.twig

{% for index, field in form.fields %}
    {% set input = attribute(field, "input@") %}
    {% if input is null or input == true %}
        {% block field %}

             <div>
                  {% block field_label %}
                      <strong>{{ field.label }}</strong>:
                  {% endblock %}
                  {% block field_value %}
                      {{ string(form.value(field.name ?? index))|nl2br }}
                  {% endblock %}
              </div>

        {% endblock %}
    {% endif %}
{% endfor %}

Any ideas to figure out?