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:

  1. FormBuilder2 Plugin saves entry and initializes the "onBeforeSave" event.

  2. 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.

  3. 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()

       craft()->on('formBuilder2_entry.beforeSave', function(Event $event)

         $url = UrlHelper::getActionUrl('formBuilder2Extension/notify/notifyAdmin', array('event' => $event));


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!

1 Answer 1


You really, really shouldn't do this.

I'm not familiar with FormBuilder, but if it is well-built, its controllers will comprise thin methods calling services to do the grunt work; services which you can also call.

If there isn't a service method which does what you want (still assuming everything is well-architected), that means the author chose not to make that functionality part of FormBuilder's API, presumably for a good reason.

If FormBuilder isn't well-built, and instead shoves a load of code in its controllers, well, that's still not a reason for you to do something similarly ill-considered.

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.