I know I can set errors and notices in the CP with setError() and setNotice(). But it gets overruled by the default error message in my event.

I have a beforeDeleteEntry event which stops the deleting of an entry by using $event->performAction = false;. This makes Craft display a default error "can't delete entry". I'd like to add more to that error or show another one, but using setError() does not work. A setNotice() is shown however so I suppose the error gets replaced by the default Craft error.

Can I do something about that?


I recently asked P&T about a similar issue, although it was for the onBeforeSaveEntry event (not onBeforeDeleteEntry) -- it turns out that you need to set the error on a specific field, not the entry as a whole. I don't know if this is the case for your problem, but perhaps worth trying something like this:

$event->params['entry']->addError('title', 'Cannot delete because blah blah blah');

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.