I am developing a component extension to create different forms for insurance.

When I create a form in backend and save it by clicking the Save or Save & Close button, I am going to create a table in database. The suitable event could be onExtensionAfterSave event in a plugin belonging to group Extension.

Now the question is this: I saw two different samples of this method:

  1. onExtensionAfterSave($data, $isNew)
  2. onExtensionAfterSave($context, &$table, $isNew)

Which is the right one?

Also to obtain paremeters, Can I use JPlugin::params (params to my extension in the backend that are already created and saved to database)?

  • 1
    Is the component your component? If so why would you listen for your own events in a plugin rather than creating the tables within your component's controller? Commented Dec 11, 2017 at 7:38
  • The component is for creating forms with different fields and input, a form might be only one page or another one multi-pages, after creation of each form, a separate table will be created according to the fields of created form. So I need to learn about the created forms field and input after it is created, the forms are quite different from each other and those forms will be used in site part, the created tables save the data to those forms after user input in the site part, created forms are not constant, they are dynamic, Events are necessary to learn about forms. Commented Dec 16, 2017 at 4:37

2 Answers 2


onExtensionAfterSave isn't a common Joomla event - It only fires when the component/module/plugin configuration is saved. Example, editing Joomla global configuration, editing the options of a component, editing the options of a module, editing the options of a plugin. I've been writing extensions for years and I've never used that event - because it just isn't useful.

I think you picked the wrong event.

It won't fire on creating a form within your component unless you've written your component to fire that event. And if you did, I'd suggest picking a different event - like onContentAfterSave, which is designed to do what you're asking for.

If it's your own component (that you're writing) - you might consider creating your own set of events to monitor. Joomla is designed to do this. I did this in one of my own components to monitor a dozen different events related to CBT training.

When you're working with your own events, you can define whatever you want to send to the plugin. In my events, most take only one variable - an ID. The plugin retrieves the data based on that ID and does whatever it's designed to do.

Step 1, choose a unique type to name your plugin folder: /plugins/YOURNEWTYPE/

Step 2, make a test plugin to define and test your events.

Step 3, load the plugins and create a dispatcher in your component to fire your custom event whenever you need it.

It's super easy.

  • 1
    I considered custom event as an alternative as long as I can use joomla events to get rid of dispatching of events separately in component, eg. plugin under group of content has no need to be dispatched separately in custom component. When the user saves component in back end, I got to create a table based on that form in which its inputs are not the same, the created form is dynamic , so both onExtensionAfterSave and onContentAfterSave are able to handle it, I will also develop a custom event plugin as you advised and I shall test all of them and may I ask what CBT training is? Commented Dec 16, 2017 at 5:06
  • 1
    About the example I said above in regard with joomla events plugin, I meant a plugin under group of search, I mentioned content mistakenly in the second line above. Commented Dec 16, 2017 at 5:29
  • 1
    I tried a test plugin, onExtensionAfterSave event did not work without being dispatched in controller, After I dispatched the event, it did and I have the id to be able to access the database to create my form. I used to create a plugin under search group, it worked without being dispatched, I expected the same here. Commented Dec 16, 2017 at 7:11
  • Sorry, but it is useful! Please don't denigrate it! It is the obvious hook to use in order to have an action as a result of someone changing something in the options. It's possible for an option to require processing to happen when it changes. The unfortunate issue is that the ComponentHelper::getParams() method still returns the old value during the onExtensionAfterSave processing, which makes it all much more difficult.
    – mbrampton
    Commented Aug 8, 2022 at 11:21
  • @mbrampton - you managed to immediately identify why I didn't find it useful.
    – Michael
    Commented Aug 23, 2022 at 19:25

The event is useful when you need custom code to be executed after saving an extension configuration. I use it in one of my templates to change favicon and logo when the color theme is changed.

onExtensionAfterSave($option, $data)

$option (string) where the plugin is called from. For a template this would be "com_templates.style".

$data (object) for a template this contains the matching row in table #__template_styles after saving, you can get the template params through json_decode($data->params).

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.