I created my own actionEntrySave for my frontend form. and I'm using the
$entryService->saveEntry($entry); method to store my entries into the database.

The problem is this does not fire

craft()->on('entries.onSaveEntry', function(Event $event) {

When I save/edit the same entry in the backend or create a new one I see an empty page with "fired" there.. (just for testing) and I can manipulate the entry the way I want without any problems. If I do the same in the frontend (saving/editing an entry) the event does not trigger but the entry saves. Can someone explain why?

Thank you very much

edit: I already tried onBeforeSaveEntry with the same result

Edit 2 Solved
I solved it now.. my error was I did this

$entryService = new EntriesService();
$dbInsert = $entryService->saveEntry($entry);

But it has to look like

$entryService = craft()->entries;
$dbInsert = $entryService->saveEntry($entry);

I thought all services were singletons. My mistake

1 Answer 1


Where is your "craft()-on()" code located?

Per the documentation, the best place is in your primary plugin file in a method named "init()".


For example, here's mine:

public function init()

    // event triggers
    craft()->on('charge.onValidate', array($this, '_validateRegistrationForm'));
    craft()->on('entries.saveEntry', array($this, '_processEditPricelistLocationForm'));
    craft()->on('entries.saveEntry', array($this, '_processEditGuestUsersForm'));
    craft()->on('entries.saveEntry', array($this, '_processGuestUserAccessForm'));
    craft()->on('entries.onBeforeSaveEntry', array($this, '_processEditGuestRemoveUsersForm'));

and here's just showing that I do in fact handle the Event $event in the method:

 * Charge onValidate
 * @param Event $event
public function _validateRegistrationForm(Event $event)
    // do stuff

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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