Return, prevent html escape

Silverstripe Version: 4.3.3

I followed the complete tutorial “How to make a simple contact form”.

My form is working fine but the problem is the <p>Text</p> tag in my return is getting converted to &lt;p&gt;Text&lt;/p&gt;

return [
            'Content' => '<p>Text</p>',
            'Form' => ''

I searched for 2 hours now on google but didn’t find a working solution.

Try using $Content.Raw

1 Like

The problem is I don’t want to replace the ‘Content’, i actually want to replace the ‘Form’. The Content should still be the same. I should have mentioned that. I already tried $Form.RAW but it doesn’t display the Form anymore.

Oh… So, I’m sure there are more elegant solutions out there, but I generally do something like this… At the end of my SendForm function I redirect back to the same page and append a success param to the URL with this…


Then I create a new function to check for that…

public function Success()
    return isset($_REQUEST['success']) && $_REQUEST['success'] == 1;

Lastly, in my template I have some logic that checks that boolean…

<% if Success %>
   <p>Success message or content var here</p>
  <% else %>
  <% end_if %>
1 Like

Awesome, this is working perfect, thanks man!

1 Like