1

I need to add an event handler for the onSaveEntry event in order to integrate with another system. In the admin screens for the form where and how do I add this event handler?

2
  • 1
    Can you confirm what type of action you need to perform on the onSaveEntry Event? In the case you are trying to trigger a notification email, Sprout Forms integrates with Sprout Email allowing notifications to be sent on the sproutForms.onSaveEntry Event. Commented Jul 11, 2016 at 14:01
  • I need to integrate it with another system, so was planing to use an API to update the external system once a form has been saved.
    – Gurney
    Commented Jul 11, 2016 at 19:01

1 Answer 1

4

Adding an event handler is not something you do through the control panel.

What you need to do is create a plugin (pluginfactory.io makes this fairly easy), and in your plugin's main class, you have an init() function that looks like this:

public function init()
{
    craft()->on('sproutForms.onSaveEntry', function (Event $event) {
        $entry = $event->params['entry']; // fetch the new entry
        ... do things with $entry ...
    });
}

If you structure your plugin properly, you will "do things with $entry" by calling a Service.

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.