Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-09T12:08:57.050Z
Answers.LastActivityDate: 2020-10-09T12:08:57.050Z
Answers.UserDisplayName: Kevon
Body: <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>
  
Tags: <plugin-development><craft3><control-panel><error-message>
Title: returning HTML in $event->sender->addErrors doesn't work
ThreadText: # 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' => '<a href='.$entry[0]->cpEditUrl.'>'.$entry[0]->title.'</a>'
  ]);
  
  ```
  
  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('<a href='.$entry[0]->cpEditUrl.'>'.$entry[0]->title.'</a>')
  ]);
  
  ```
  
  PS: don't forget to add this to the top of your php file:
  
  ```
  use craft\helpers\Template;
  
  ```
  
  
  ---
  
  