We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Disable flashSession auto escaping in phalcon 3

How can I disable auto escaping for an individual flashSession message? Here's an example of what I am doing in my controller;

$this->flashSession->warning('<div class="header">Warning!</div><div class="content">This is a warning message...</div>');

The divs in the code above get escaped in Phalcon 3. How can I disaable escaping for this message so it displays correctly?

I recommend use template volt:

{% if flashSession.has('warning') %}
  <div class="ui icon warning message">
    <i class="close icon"></i>
    <i class="warning circle icon"></i>
    <div class="content" style="text-align: left">
      <div class="header">
      {% set messages = flashSession.getMessages('warning') %}
      {% if messages | length == 1 %}
        {% for message in messages %}
          <p>{{ message }}</p>
        {% endfor %}
      {% else %}
        <ul class="list">
          {% for message in messages %}
            <li>{{ message }}</li>
          {% endfor %}
      {% endif %}
{% endif %}

equals for: error, notice and success.

edited Sep '16

Add $flash->setAutoescape(false); to your service definition. Here is mine:

// Flash messages
$di->set('flash', function() {
    $flash = new \Phalcon\Flash\Session();
    return $flash;