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?
1 Answer
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.
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 thesproutForms.onSaveEntry
Event.