<p>Allright, after digging &amp; debugging a bit further into this issue I found it out myself!</p>
<pre><code>$event-&gt;sender-&gt;addErrors([
    'expiryDate' =&gt; Template::raw('&lt;a href='.$entry[0]-&gt;cpEditUrl.'&gt;'.$entry[0]-&gt;title.'&lt;/a&gt;')
]);
</code></pre>
<p>PS: don't forget to add this to the top of your php file:</p>
<pre><code>use craft\helpers\Template;
</code></pre>

CC BY-SA 4.0
2020-10-09T12:08:57.050Z
2020-10-09T12:08:57.050Z
Kevon
<p>I have a plugin which is checking if there is a duplicate entry before save. I'm trying to give the user back an anchor to the entry which exists so my client can switch without searching for it in a giant structure.</p>
<p>I have this code</p>
<pre><code>$event-&gt;sender-&gt;addErrors([
    'expiryDate' =&gt; '&lt;a href='.$entry[0]-&gt;cpEditUrl.'&gt;'.$entry[0]-&gt;title.'&lt;/a&gt;'
]);
</code></pre>
<p>But somehow I can't render the HTML correctly in the Control Panel, it's getting displayed as plain tekst. Is there any way to achieve this?</p>

<plugin-development><craft3><control-panel><error-message>
returning HTML in $event->sender->addErrors doesn't work
# returning HTML in $event->sender->addErrors doesn't work

(Asked by: username_0 on 2020-10-09)

I have a plugin which is checking if there is a duplicate entry before save. I'm trying to give the user back an anchor to the entry which exists so my client can switch without searching for it in a giant structure.
I have this code
$event->sender->addErrors([
    'expiryDate' => ''.$entry[0]->title.''
]);

But somehow I can't render the HTML correctly in the Control Panel, it's getting displayed as plain tekst. Is there any way to achieve this?

**Tags:** plugin-development, craft3, control-panel, error-message


---

## 1 answers

### Answer by username_0 on 2020-10-09. Score: 1 | Accepted answer

Allright, after digging & debugging a bit further into this issue I found it out myself!
$event->sender->addErrors([
    'expiryDate' => Template::raw(''.$entry[0]->title.'')
]);

PS: don't forget to add this to the top of your php file:
use craft\helpers\Template;


---

