Create a plugin with onExtensionBeforeSave
and/or onExtensionAfterSave
event.
public function onExtensionBeforeSave($context, $item, $isNew)
{
// Check that we are editing our module.
if ($context !== 'com_modules.module' || $item->module !== 'mod_example')
{
return true;
}
// Do stuff here.
$params = new JRegistry($item->params);
// Our stuff fails, don't save the module.
if (!$this->doStuff($params))
{
return false;
}
return true;
}
Alternative way, which may or may not be suitable in your case, is to create a form validation rule in your module. This would not require a plugin. See documentation https://docs.joomla.org/Server-side_form_validation.