1

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?

1

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;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.