Skip to main content

Events, plugins and registries

What it does​

This page lists the server-side places where your own Magento module can hook into WebForms: the events WebForms dispatches, the plugins it already declares on its own classes and on Magento's, and the DI registries that add-ons fill. Each entry names the file in the MageMe_WebForms module, so you can read the code around it. When an event fires and what each payload value holds is described on Events reference.

Before you start​

  • A Magento module of your own with MageMe_WebForms in the <sequence> of its etc/module.xml. Never edit files inside the WebForms modules; they are replaced on every update.
  • Declare observers and plugins in the area where the code runs. Submissions arrive from the storefront, the admin, REST, GraphQL and the command line, so an observer for submissions belongs in the global etc/events.xml.
  • After a change to di.xml or events.xml, run bin/magento setup:di:compile on a compiled install and clean the cache.

Steps​

React to an event​

Declare an observer for the event in etc/events.xml, and read the payload with $observer->getData('<key>'). File paths are relative to the module named in the heading of each table.

MageMe_WebForms: submissions

Event Dispatched at Payload keys
webforms_validate_post_result Helper/Result/PostHelper.php, on submit and on the Review Before Submit step (nothing saved) form, postData, validate
webforms_result_submit Helper/Result/PostHelper.php result, is_new
webforms_result_save Model/ResourceModel/Result.php result
webforms_result_load Model/ResourceModel/Result.php result
webforms_result_delete Model/ResourceModel/Result.php result
webforms_result_collection_load Model/ResourceModel/Result/Collection.php collection
webforms_result_approve Controller/Adminhtml/Result/SetStatus.php, Model/Result/Mass/BulkUpdate.php result
webforms_result_status_changed Model/Status/AssignmentService.php result_id, old_status_id, new_status_id, actor_id
webforms_result_status_mass_changed Model/Status/AssignmentService.php new_status_id, result_ids, actor_id, counts
webforms_controller_result_access Model/Customer/Access/OwnershipHook.php access, result, capability

MageMe_WebForms: forms, fields and admin screens

Event Dispatched at Payload keys
webforms_form_duplicate Model/Form.php form, elementMatrix
webforms_form_import Helper/Form/ImportHelper.php form, elementMatrix
webforms_fields_tohtml_html Model/Field/AbstractField.php field, html_object
webforms_form_prepare_save Controller/Adminhtml/Form/Save.php form, request
webforms_builder_draft_activity Controller/Adminhtml/AbstractBuilderJsonAction.php form_id
webforms_fieldset_prepare_save Controller/Adminhtml/Result/Save.php result (the submission, despite the event's name), form, request
webforms_quickresponse_prepare_save Controller/Adminhtml/Quickresponse/Save.php, Controller/Adminhtml/QuickresponseCategory/Save.php form (the quick response or category), request
webforms_block_adminhtml_results_edit_form_prepare_layout_field Ui/Component/Result/Form/Modifier/Answers.php, once per field of the submission edit form field, config; form and fieldset are null since the edit form became a UI component
webforms_ui_component_result_listing_columns_prepare_config Ui/Component/Result/Listing/Columns.php field, column_config
webforms_integration_lists_refreshed Ui/Component/Form/Form/Modifier/Integration/AbstractIntegrationSettings.php code, store_id, form, outcomes, labels

MageMe_WebForms: uploaded files. One dispatch, Model/ResourceModel/AbstractFile.php (and Model/ResourceModel/FileDropzone.php, which deletes its files itself), payload file, under the name the resource model sets in its DELETE_EVENT_NAME constant:

Event Resource model
webforms_files_delete Model/ResourceModel/FileDropzone.php
webforms_dropzone_delete Model/ResourceModel/TmpFileDropzone.php
webforms_file_gallery_delete Model/ResourceModel/FileGallery.php
webforms_tmp_file_gallery_delete Model/ResourceModel/TmpFileGallery.php
webforms_file_message_delete Model/ResourceModel/FileMessage.php
webforms_tmp_file_message_delete Model/ResourceModel/TmpFileMessage.php
webforms_file_customer_notification_delete Model/ResourceModel/FileCustomerNotification.php
webforms_tmp_file_customer_notification_delete Model/ResourceModel/TmpFileCustomerNotification.php

MageMe_WebFormsApi

Event Dispatched at Payload keys
webforms_result_approve Model/Service/Submission.php (REST approval update) result

WebForms also dispatches two Magento events: customer_login after it registers and signs in a customer from a form (Observer/RegisterCustomerOnSubmissionObserver.php), and clean_cache_by_tags (Model/Terms/RevisionManager.php, Model/Field/RemoteOptions/FormPages.php, Model/Cache/CleanDeferral.php). The WebForms GraphQL module, the Hyvä and Breeze companions and the add-ons dispatch no events of their own. The standard model events under each model's _eventPrefix, such as webforms_result_save_commit_after, are listed on Events reference.

WebForms observes these events itself, so your observer runs next to them:

Event Core observer Declared at
customer_delete_before Observer\CustomerDeleteBeforeObserver etc/events.xml
webforms_result_save Observer\RegisterCustomerOnSubmissionObserver etc/events.xml
webforms_result_approve Observer\RegisterCustomerOnApprovalObserver etc/events.xml
webforms_form_import Observer\RemapRegistrationMapObserver, Observer\Integration\RemapOnImport etc/events.xml
webforms_form_duplicate Observer\RemapRegistrationMapObserver, Observer\Integration\RemapOnImport etc/events.xml
webforms_result_save_commit_after Observer\RefreshResultSnapshotObserver, Observer\RefreshInboxProjectionObserver, Observer\AssignDefaultAssigneeObserver etc/events.xml
checkout_agreement_save_after, checkout_agreement_delete_after Observer\Terms\AgreementChangedObserver etc/events.xml
webforms_result_delete Observer\RecordResultTombstoneObserver etc/events.xml
store_delete_before Observer\TouchSubmissionsBeforeOwnerDelete etc/events.xml
webforms_builder_draft_activity Observer\BuilderDraftActivity etc/adminhtml/events.xml
admin_system_config_changed_section_system Observer\RefreshEmailReadinessOnMailSwitch etc/adminhtml/events.xml
webforms_integration_lists_refreshed Observer\Integration\RefreshListsMessage etc/adminhtml/events.xml
customer_login Observer\RefreshSectionsOnLogin etc/frontend/events.xml

Add a plugin​

Declare a plugin in your module's di.xml. Prefer the interfaces in MageMe\WebForms\Api, such as FormRepositoryInterface and ResultRepositoryInterface, over concrete classes. WebForms already declares these plugins; one of yours on the same method runs before or after them by sortOrder. All files are in MageMe_WebForms.

On WebForms classes

Target Methods Plugin Area sortOrder Declared at
Api\FormRepositoryInterface beforeSave Plugin\Repository\ConfirmationNormalizePlugin global 100 etc/di.xml
Api\FormRepositoryInterface afterSave Plugin\Confirmation\EnsureDefaultConfirmation global 200 etc/di.xml
Api\FormRepositoryInterface afterSave Plugin\Confirmation\FormConfirmationWriteThrough global 210 etc/di.xml
Api\FormRepositoryInterface afterGetById, afterGetByCode, afterGetPublicById Plugin\Confirmation\FormConfirmationRead global 220 etc/di.xml
Api\FormRepositoryInterface beforeSave Plugin\Repository\DefaultAssigneeGuardPlugin global 110 etc/di.xml
Model\ResourceModel\Notification afterTransitionActive Plugin\Repository\RefreshEmailReadinessByNotificationPlugin global — etc/di.xml
Model\Notification\Document\NotificationWriter afterPublish Plugin\Repository\RefreshEmailReadinessByNotificationPlugin global — etc/di.xml
Api\FormRepositoryInterface afterSave Plugin\Repository\RefreshEmailReadinessOnFormSavePlugin global — etc/di.xml
Model\ResourceModel\Field beforeSave Plugin\Terms\TermsFieldGuardPlugin global 90 etc/di.xml
Model\ResourceModel\Field afterSave Plugin\Terms\FieldSaveRevisionPlugin global 100 etc/di.xml
Model\ResourceModel\Form beforeSave Plugin\Terms\FormNoStorageGuardPlugin global 90 etc/di.xml
Api\StoreRepositoryInterface beforeSave Plugin\Terms\TermsStoreOverrideGuardPlugin global 90 etc/di.xml
Api\StoreRepositoryInterface afterSave, afterDelete Plugin\Terms\StoreOverrideRevisionPlugin global 100 etc/di.xml
Api\FormRepositoryInterface beforeSubmitById Plugin\Terms\RestSubmitTermsRejectPlugin global 90 etc/di.xml
Model\Form beforeSaveStoreData Plugin\Confirmation\StoreDataToConfirmation global 100 etc/di.xml
Helper\Result\PostHelper aroundPostResult Plugin\Helper\Result\PostHelper\DiscardUnstoredSubmission global −1000000 etc/di.xml
Controller\Adminhtml\DraftLockGuardedInterface aroundExecute Plugin\Controller\DraftLockPlugin adminhtml — etc/adminhtml/di.xml
Controller\Adminhtml\LicenseGuardedInterface aroundExecute Plugin\Controller\LicenseGuardPlugin adminhtml — etc/adminhtml/di.xml
Controller\Adminhtml\Form\Save, Result\Save, Message\Save beforeExecute Plugin\Controller\Adminhtml\StripNavigationParams adminhtml −10 etc/adminhtml/di.xml
Controller\Adminhtml\Field\UpdateLayout beforeExecute Plugin\Controller\Adminhtml\Field\UpdateLayout\DecodePackedPost adminhtml 10 etc/adminhtml/di.xml
Api\FieldRepositoryInterface aroundDelete Plugin\Repository\FieldTrashPlugin adminhtml — etc/adminhtml/di.xml
Controller\Form\Preview beforeExecute Plugin\Controller\Form\PreviewTokenPlugin frontend — etc/frontend/di.xml

On Magento classes

Target Methods Plugin Area Declared at
Magento\Widget\Model\Template\Filter beforeFilter Plugin\Widget\SeparateRepeatedDirectives global etc/di.xml
Magento\Framework\DB\Adapter\AdapterInterface afterCommit, afterRollBack Plugin\Import\RecordTransactionBoundaries global etc/di.xml
Magento\Framework\DB\Adapter\AdapterInterface aroundCommit, aroundRollBack Plugin\Db\SettleCopyWork global etc/di.xml
Magento\Framework\DB\Adapter\Pdo\Mysql afterCloseConnection Plugin\Db\SettleCopyWorkOnClose global etc/di.xml
Magento\Framework\Acl\Builder afterResetRuntimeAcl Plugin\Magento\Acl\ForgetAllowedForms global etc/di.xml
Magento\Framework\App\Cache aroundClean Plugin\Cache\DeferTaggedClean global etc/di.xml
Magento\User\Model\ResourceModel\User beforeDelete Plugin\User\TouchSubmissionsBeforeUserDelete global etc/di.xml
Magento\Framework\Setup\Declaration\Schema\OperationsExecutor beforeExecute Plugin\Setup\RenumberDuplicateReferenceNumbers global etc/di.xml
Magento\Framework\Setup\Declaration\Schema\OperationsExecutor beforeExecute Plugin\Setup\CollapseDuplicateResultValues global etc/di.xml
Magento\Framework\Acl\AclResource\Provider afterGetAclResources Plugin\Adminhtml\TreeBuilder adminhtml etc/adminhtml/di.xml
Magento\Store\Model\ResourceModel\Store afterSave Plugin\Store\View adminhtml etc/adminhtml/di.xml
Magento\Cms\Model\Wysiwyg\CompositeConfigProvider afterProcessWysiwygConfig Plugin\Magento\Cms\Model\Wysiwyg\FieldToolbar adminhtml etc/adminhtml/di.xml
Magento\Customer\Model\Customer\DataProvider, DataProviderWithDefaultAddresses afterGetMeta Plugin\Magento\Customer\Model\Customer\DataProviderWithDefaultAddresses\CustomerResultListing adminhtml etc/adminhtml/di.xml
Magento\Reports\Model\ResourceModel\Refresh\Collection afterLoadData Plugin\Magento\Reports\Model\ResourceModel\Refresh\Collection\LoadData adminhtml etc/adminhtml/di.xml
Magento\Widget\Block\Adminhtml\Widget\Options afterAddFields Plugin\Widget\Block\Adminhtml\Widget\Options\LockOutOfRoleFormPicker adminhtml etc/adminhtml/di.xml
Magento\Config\Controller\Adminhtml\System\Config\Save afterExecute Plugin\Magento\Config\KeepBuilderReturnOnSave adminhtml etc/adminhtml/di.xml
Magento\Contact\Block\ContactForm beforeToHtml Plugin\ContactForm frontend etc/frontend/di.xml
Magento\Customer\Block\Form\Register beforeToHtml Plugin\Magento\Customer\Block\Form\Register frontend etc/frontend/di.xml
Magento\Customer\Controller\Address\FormPost, Delete afterExecute Plugin\Customer\RefreshSectionsAfterAddressChange frontend etc/frontend/di.xml
Magento\Framework\Session\SessionStartChecker afterCheck Plugin\Session\SkipForVersionedScripts frontend etc/frontend/di.xml

Register in a registry​

A registry is a class whose constructor takes an array that di.xml fills. Add an <item> to the argument in your module's di.xml, in the area the table names. These registries exist for add-ons. All but the form-settings modifier pool start empty in WebForms:

Registry Argument Item implements Area Filled by
Model\Integration\DefinitionPool definitions Api\IntegrationDefinitionInterface global The integration add-ons
Model\Integration\HandlerPool handlers Api\IntegrationHandlerInterface global The integration add-ons
Model\Notification\Render\ContributedVariables contributors Model\Notification\Render\VariableContributorInterface (variables(), values(ResultInterface)) global Cart Quote, Product Request, Hide Price
Model\Result\AnswerRow\ExtraAnswerRows providers Model\Result\AnswerRow\AnswerRowProviderInterface (rows(ResultInterface, string $context), contexts account, admin, email, public) global Cart Quote, Product Request, Hide Price
Ui\DataProvider\Product\Form\Modifier\FormPickers attributeCodes the code of a product attribute that holds a form id adminhtml Product Request, Product Options
Ui\Component\Form\Form\Modifier\Pool (virtual type in etc/adminhtml/di.xml) modifiers Magento\Ui\DataProvider\Modifier\ModifierInterface, with class and sortOrder adminhtml The integration add-ons, for their section in the form settings

WebForms' own form-settings sections are in the modifier pool too, at sortOrder 137 to 200: choose a sortOrder that places yours where you want it among them. Modifiers that work on the whole form run after them, at 400 and 900, and three that must see every section, add-on sections included, run last, at 100000 to 100200.

How the two integration pools work together is on Add-on integration contract.

Field types and CAPTCHA providers are registered in etc/webforms.xml (field_types, captcha_types), which Magento merges across modules; see Custom field type and Custom CAPTCHA provider. Form templates and PDF templates have their own merged files, etc/webforms_templates.xml and etc/webforms_pdf_templates.xml. PDF output goes through Model\Pdf\Render\PdfRendererInterface, which etc/di.xml points at MpdfRenderer; a preference of your own replaces it.

WebForms fills these registries itself. They are not marked @api, and no MageMe add-on adds to them:

Registry Argument Declared at
Model\Logic\Operator\OperatorRegistry operators, consumers etc/di.xml
Model\Notification\Trigger\TriggerRegistry triggers etc/di.xml
Model\Notification\WrapperRegistry contracts etc/di.xml
Model\Inbound\Auth\AuthStrategyPool strategies etc/di.xml
Model\Inbound\Webhook\WebhookAdapterPool adapters etc/di.xml
Model\Inbound\Auth\OAuthProviderPool providers etc/di.xml

Read the current form or submission​

WebForms doesn't put the form, the submission or the status into Magento's Registry, on admin pages or on the storefront. Code that needs them on a page takes a holder class in its constructor and calls get(), which returns null when the page set nothing. A plugin that hands a form or a submission to a WebForms block calls set() on the holder.

What you need Holder or source
The form of the page (admin pages, a form's account page) Model\Context\CurrentForm
The submission of the page (admin pages, a submission's account page) Model\Context\CurrentResult
The status being edited (admin) Model\Context\CurrentStatus
Whether the request previews a draft Block\Form\Context::getPreviewState() (Model\Context\PreviewState)
The customer on an account page Magento\Customer\Model\Session::getCustomerId()
The page address a form block was shown on The block's own data, current_url
The product of a product page (a form block subclass) Magento\Catalog\Helper\Data::getProduct()
// MageMe\WebForms\Model\Context\CurrentForm $currentForm in the constructor
$form = $this->currentForm->get();

An admin button of your own that extends Block\Adminhtml\Common\Button\Generic or AclGeneric and declares a constructor takes Block\Adminhtml\Common\Button\ButtonContext and passes only it to the parent. Base classes that changed their constructors, and the members that are gone, are listed in the upgrade notes of the module, UPGRADE.md, under Code written against the 3.x PHP API.

What you should see​

  • An observer declared in the global etc/events.xml runs for storefront, admin, REST and GraphQL submissions alike; one declared in etc/frontend/events.xml runs only for storefront requests.
  • After setup:di:compile, a plugin on an Api\ interface wraps every implementation the object manager hands out for it, including the repositories WebForms injects into its own classes.
  • An item added to a registry is there on the next request; a registry that checks its items, such as DefinitionPool or HandlerPool, throws InvalidArgumentException on the first use when an item is of the wrong type.

Limits​

  • PostHelper::postResult() must keep DiscardUnstoredSubmission as its outermost plugin (sortOrder −1000000): it deletes a submission of a form that does not store submissions after every other plugin and observer has run. Give your own plugins on postResult() a higher sortOrder, and never call postResult() again from inside it.
  • FieldTrashPlugin replaces FieldRepositoryInterface::delete() in the admin and never calls $proceed: a field deleted there goes to the trash. Plugins on that method that come after it in sort order, and the repository's own delete(), do not run in the admin.
  • Mass approval from the grid and workflow status changes write to the database directly. A mass approval fires webforms_result_approve once per changed submission; a status change fires webforms_result_status_changed, or webforms_result_status_mass_changed once for a mass change. None of them fires webforms_result_save or the model's save events.
  • webforms_field_prepare_save, webforms_fieldset_prepare_save (for a section) and webforms_logic_prepare_save aren't dispatched when a field, a section or a logic rule is saved: the form builder saves them when the form is published, with no event per element. An observer on them is never called, without an error. webforms_fieldset_prepare_save still fires from the submission edit page, as in the table above.
  • webforms_result_save and webforms_result_submit fire for edits too. Check is_new on webforms_result_submit to act only on new submissions.
  • New submissions reach integrations through DefinitionPool, not through an observer. The deprecated PostResult plugins and the SendToZapier observer still in the integration add-ons do nothing and are not registered.

Troubleshooting​

Symptom Check
The observer never runs The area of the events.xml file against the Area column on Events reference; MageMe_WebForms in your module's <sequence>; the cache cleaned.
The observer runs again when a submission is edited It listens to webforms_result_save, which fires on every save; use webforms_result_submit and check is_new.
A plugin on a concrete WebForms class does nothing The caller may use the Api\ interface and get another implementation; put the plugin on the interface. On a compiled install, run setup:di:compile.
InvalidArgumentException naming a pool after you added an item The item does not implement the interface the pool expects, or a definition's getCode() differs from its item name.

What's next​

Applies to WebForms 4Last reviewed October 14, 2026