[🕷️Bug]: Form Builder Add-on Strips Line Breaks From Textarea Fields In Email Body. - Question | JoomShaper

[🕷️Bug]: Form Builder Add-on Strips Line Breaks From Textarea Fields In Email Body.

Brad Thompson

Brad Thompson

SP Page Builder 2 weeks ago

Component: SP Page Builder → Form Builder add-on Versions affected: 6.7.1, 6.8.0 (likely all 6.x) File: components/com_sppagebuilder/addons/form_builder/site.php

Description: When a user submits a Form Builder form containing a textarea field (e.g., a message field), line breaks in the textarea content are lost in the delivered email. Multi-line messages arrive as a single flattened line which is hard to read if long.

Root cause: The Form Builder add-on sends emails in HTML mode ($isHtmlMode = true at line ~928) but does not convert newlines to <br> tags before substituting field values into the email template. At line ~876:

$emailBody = str_replace("{{" . $name . "}}", $value, $emailBody);

The raw $value (which contains \n from textarea input) is inserted directly into the HTML email body. HTML email clients treat bare \n as whitespace, collapsing multi-line content into a single line.

The older ajax_contact add-on handles this correctly with nl2br():

$message = nl2br($input['value']);  // ajax_contact/site.php, line ~361

The form_builder add-on is missing the equivalent call.

Suggested fix: Apply nl2br() to field values when substituting into the HTML email body:

$emailBody = str_replace("{{" . $name . "}}", nl2br($value), $emailBody);

This is a no-op for single-line inputs (text, email, phone) since they contain no newlines. Only textarea fields are affected. The email subject substitution should remain unchanged (subjects should be single-line).

Steps to reproduce:

  1. Create a Form Builder form with a textarea field
  2. Submit the form with multi-line content (press Enter between lines)
  3. Check the received email — line breaks are missing
0
1 Answers
Mehtaz Afsana Borsha
Mehtaz Afsana Borsha
Accepted Answer
Support Agent 2 weeks ago #231782

Hi,

Thank you for bringing this detailed report to our attention. I have forwarded the information to our technical team for review.

Best regards,

0