3

I want to use an <a> inside a flashMessenger message.

For example: In my website I have some blog posts, and when I delete one of them, I want to show a message like: "Success! <a>Undo</a>"

My code:

  $restore = $this->url()->fromRoute('news/restore', array('id' => $id));
  $this->flashMessenger()->addSuccessMessage("Success. <a href='$restore'>Undo</a>");
  return $this->redirect()->toRoute('news');

But It doesn't work when I put that <a> inside the message. How can I do that?

4

1 回答 1

5

它对我有用的方式:

<?php if($this->flashMessenger()->hasMessages()): ?>

    <div class="alert alert-info flash-messenger">
        <?=$this->flashMessenger()->setAutoEscape(false)->render(); ?>
    </div>

<?php endif; ?>

默认情况下,autoEscape 属性设置为true

工厂?也许?

资源:

https://github.com/zendframework/zend-view/blob/master/src/Helper/FlashMessenger.php

于 2016-02-15T03:18:57.173 回答