This is a 2 part question regarding output message in html after submitting through a contact form.
How do I call the html template file in the email plugin ‘base.html.twig’? The way I have done it is to copy and paste the content over the ‘data.html.twig’ and edit to my liking. This doesn’t seem to be the correct way, but it works.
How to render the message to full html such as hyperlinks, line breaks, etc? Right now the message is outputted as one block of text. The hyperlink and line breaks doesn’t work.
I am aware that textarea doesn’t support html and only text. However, there is a php script floating around the net created for wordpress that can accomplish this in a form of a ‘function _make_url_clickable_cb()’
The default behavior is to just send the data, without that base.html.twig which is only used when calling EmailUtils::sendEmail programatically (in PHP).
You can still do it: put the email base twig in your theme, under templates/email/base.html.twig. You can customize it there, and instead of adding {{ content|raw }} in the body, add {% block content %},{% endblock %}. In templates/form/data.html.twig, use
{% extends 'email/base.html.twig' %}
{% block content %}
{% for index, field in form.fields %}
..... content of the default data.html.twig
{% endfor %}
{% endblock %}
the content of user input is escaped by default. You can customize everything in your data.html.twig file, but filtering is there for security reasons.