I am working on extending the formbuilder2 plugin to call and pass the $event variable to a custom Controller after FormBuilder2 has initialized the "onBeforeSave" event within the FormBuilder2 Entry_Controller.
Background Info
- Trying to extend the Formbuilder2 plugin
- My plugin is called FormBuilder2ExtensionPlugin
- Trying to call a Controller Function from within my FormBuilder2Extension_NotifyController and pass $event variables.
- Within my FormBuilder2Extension_NotifyController, I am calling the actionNotifyAdmin($event) function.
My Plugin Logic:
FormBuilder2 Plugin saves entry and initializes the "onBeforeSave" event.
FormBuilder2Extension Plugin listens for "onBeforeSave" event, and triggers a custom controller function to run. Note: Must be able to pass the $event variables to the new FormBuilder2Extension controller function as well.
FormBuilder2Extension Controller will then parse $event data, and run other FormBuilder2 Controller & Service functions using the $data, so I will need to link from FormBuilder2Extension Controller functions to Formuilder2 Controller functions.
My Problem:
- Cannot figure out how to run a Controller Function from within the init() event listener and pass the $event variables as well.
My Current Code: (within main plugin file)
public function init()
{
parent::init();
craft()->on('formBuilder2_entry.beforeSave', function(Event $event)
{
$url = UrlHelper::getActionUrl('formBuilder2Extension/notify/notifyAdmin', array('event' => $event));
return;
});
}
Closing Remarks:
It works if I use a service function.
Example: craft()->formBuilder2Extension_notify->notifySubmitterOfSubmission($event);
But I would rather not rewrite the same Controller & Service functions that formbuilder2 has already written and place it within my service folder.
Any thoughts…? Thanks!