Is there a simple way to exclude Captcha from email body?

I’ve just managed to set up a form with reCaptcha, which is working fine, only the Capthcha is shown in the email body, AND on the thank you page, somethng like this:

Name: Myself
Message: Some message
Captcha: 03AHJ_VutMichYe-5UdzUDY2zqjHnB4FVuJecKkJS2N0y8zI2rvfzXjbIU_IIizXZWSjvb nh80xCmyQekIbWLnRsvlNqzdhkUl18nOAniSET6wHKzKuOacc61E6A139tBlCmWQ_wijKlPPRSDKbLeyQqHq48ra1jOL7MScJTZmqRbboBXigTBAg6t4pKurQ0FYQVcdAkj6WuO-4U5gZmbmahvY2GqaWc8nN02OPrEkM-6mmd3kQzOEVuSoO1R5eXyy2ouz9xQZbW89AEmp-sLFBBqCc9-XyS87-8OnVvAek2c1y0AE_BoBb5sb2mdCwacnwgi9AmckoTCFRtaSbve64l8WFRF7KxKAZc9adHzViOacfwhOqwAbblXTchf47L2J0n5kPqWnuDoLR-4SmcZ4yFZzUyaG4srQC8jw7iD9oBkvPbbPIBOG-zktkKv_vEopyyW_SQAAqZS7gH8Sw-Hwn9z7fb2O3bg1FxXLhcwADuAchU1fxhQuZODpXSKtImIVGIbIEDXilBcy8BA02uI7XH-Cf9Afyr0FoJLJn9V7i2qfsCDO_2eJmmgL9RNSzy3mEzgSjyEq4uNzS46Xa_HbfLBKLBoJsx_ujvWxZwwgGIxuPqghXlaIzYiCBXzfASY_r6MFZ_tWuSExudwoRLnDb98jHhK08s4JZ9WiXD-zTJUVPVTbQhvSEvud0kd5LKnaOR6J7L2u53rE_lga1YsI0DfKijdKQ9Y7gQqmppU2KmCEj9cGiRJtM6tLgfxhie0D8ZnKoH4EQ4AfevrxVTIUR7IavcPRxqp8mXe3fPx6HgSnbYJ1bAimRp8f05Fj-u4rS7E2tF s3WVLfW8Tt5cVpZlqKwJd-DBfUbpxNCLdIROSDChpo2WKfTa-4TEAAeckqbdSGNi6Yd9XqDhfizcdlryDf2sGSVbubxf3Ur7ufI2taAjfnqutlcSchTc8RDOZw8CjzEViZrhFdb1FVK1j858khsMKFQ2s0wYUcLEkkPnFQbKTJSjstYqs

I’ve checked the twig file, but the way it’s done is beyond my capabilities (or I’m just too lazy to dig in)
My question is, what would be the simplest way to hide this?

OK never mind, I managed to filer out the filed name in the default/data.html.twig like

{% if!='g-recaptcha-response' %}
    <div>{% block field_label %}<strong>{{ field.label }}</strong>{% endblock %}: {% block field_value %},{{ string(form.value(|e) }},{% endblock %}</div>
{% endif %}

Probably not so lazy after all. :slight_smile:

I have run into the same issue. Unfortunately, the snippet shown above is not working for me. I suspect that there is some missing information on how to enable this snippet.

I’m still in the learning process here. What I did was paste the above code into: user/plugins/form/template/forms/data.html.twig
It had no effect.

From my reading of the snippet it is saying, "print everything that does not have a field name of g-recaptcha-response.

Other than the ugly re-capthca code in the email alert and the thank you page, the form seems to be working fine.

Looking forward to sorting this out so that I can experiment with the other field types.

IMHO, best fix would be to be to set a parameter like readonly:truein the form field setup. Tried this but it didn’t work.

Never mind… SOLVED

Looked into the plugins folder more carefully.

Here are the complete instructions for removing the re-captcha code in the email and thankyou page:


replace existing code with:

{% for field in form.fields %}
{% block field %}
    {% if!='g-recaptcha-response' %}
    <div>{% block field_label %}<strong>{{ field.label }}</strong>{% endblock %}: {% block field_value %},{{ string(form.value(|e) }},{% endblock %}</div>
    {% endif %}
{% endblock %}
{% endfor %}

There may be a better place for Grav to access this altered code? Perhaps in user/config/? Suggestions?

I will add a setting to the form plugin to allow excluding some fields from the form output automatically.

Gracias, tengo el mismo problema. Voy a probar esta solución.