Form Plugin: customize field type checkboxes

Hey guys,
I’m building a large form right now. I need to modify the checkboxes field type. Which works fine, if I copy the folder and template file to my own theme. But I need to create a new field type, something like checkbox-images, to also keep the original checkboxes field type.

So I copied the modified checkboxes folder with the checkboxes.html.twig file and renamed folder and file to checkboxes-images, then I changed the field type inside the from

        type: checkboxes
        display_label: false


        type: checkboxes-image
        display_label: false

The rendering of my checkbox fields frontendwise is working as aspected.
Unfortunately the selected checkboxes fields do not get rendered inside the email sent by the form. I already changed the data.html.twig template to

   {% block field_value %}
          {% if field.type == 'checkboxes-images' %}
              {% set use_keys = field.use is defined and field.use == 'keys' %}
              {% for key,value in form.value(scope ~ %}
                {% set index = (use_keys ? key : value) %}
                      {{ field.options[index].name|e }}
              {% endfor %}
          {% elseif field.type == 'checkbox' %}

But this does not work. At this point I’m stuck. Everything works if I change the original file, but if I copy the file and rename the `field type, the checkboxes field does not get rendered inside the email. Any help? :sweat_smile:

Did you find a solution?

Not really… it works if you use the original checkboxes field, but if you try to use a different template it doesn’t work. Looks like somewhere inside the form plugin is some hidden magic I couldn’t find.

Maybe @rhuk has an idea? :slight_smile: