From 8b84e0d01acfe8eac162e7ca6c995e7c01005dfa Mon Sep 17 00:00:00 2001 From: Lina Wolf <48202465+linawolf@users.noreply.github.com> Date: Sun, 11 Oct 2026 11:43:51 +0200 Subject: [PATCH 1/2] [DOCS] Document the form state and validation configuration events AfterFormStateInitializedEvent and AfterFormDefinitionValidationConfigurationIsBuiltEvent replace the last two hooks of EXT:form. Neither event had a page yet. Resolves: https://github.com/TYPO3-Documentation/Changelog-To-Doc/issues/1803 Resolves: https://github.com/TYPO3-Documentation/Changelog-To-Doc/issues/1804 Releases: main Assisted-by: Claude Opus 5.5 Signed-off-by: Lina Wolf --- ...ionValidationConfigurationIsBuiltEvent.rst | 42 +++++++++++++++++++ .../Form/AfterFormStateInitializedEvent.rst | 41 ++++++++++++++++++ .../ApiOverview/Events/Events/Form/Index.rst | 10 +++-- .../_CustomPropertyPathListener.php | 25 +++++++++++ .../_CampaignFromQueryListener.php | 27 ++++++++++++ ...alidationConfigurationIsBuiltEvent.rst.txt | 20 +++++++++ .../AfterFormStateInitializedEvent.rst.txt | 13 ++++++ 7 files changed, 174 insertions(+), 4 deletions(-) create mode 100644 Documentation/ApiOverview/Events/Events/Form/AfterFormDefinitionValidationConfigurationIsBuiltEvent.rst create mode 100644 Documentation/ApiOverview/Events/Events/Form/AfterFormStateInitializedEvent.rst create mode 100644 Documentation/ApiOverview/Events/Events/Form/_AfterFormDefinitionValidationConfigurationIsBuiltEvent/_CustomPropertyPathListener.php create mode 100644 Documentation/ApiOverview/Events/Events/Form/_AfterFormStateInitializedEvent/_CampaignFromQueryListener.php create mode 100644 Documentation/CodeSnippets/Events/Form/AfterFormDefinitionValidationConfigurationIsBuiltEvent.rst.txt create mode 100644 Documentation/CodeSnippets/Events/Form/AfterFormStateInitializedEvent.rst.txt diff --git a/Documentation/ApiOverview/Events/Events/Form/AfterFormDefinitionValidationConfigurationIsBuiltEvent.rst b/Documentation/ApiOverview/Events/Events/Form/AfterFormDefinitionValidationConfigurationIsBuiltEvent.rst new file mode 100644 index 0000000000..e8ef889ed7 --- /dev/null +++ b/Documentation/ApiOverview/Events/Events/Form/AfterFormDefinitionValidationConfigurationIsBuiltEvent.rst @@ -0,0 +1,42 @@ +.. include:: /Includes.rst.txt +.. index:: Events; AfterFormDefinitionValidationConfigurationIsBuiltEvent + +.. _AfterFormDefinitionValidationConfigurationIsBuiltEvent: + +======================================================== +`AfterFormDefinitionValidationConfigurationIsBuiltEvent` +======================================================== + +.. versionadded:: 15.0 + :changelog: feature-109849-1716115200 + + The event replaces the removed hook + :php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['buildFormDefinitionValidationConfiguration']`. + +The event +:php:`\TYPO3\CMS\Form\Event\AfterFormDefinitionValidationConfigurationIsBuiltEvent` +is dispatched after the validation configuration of the form editor has +been built for a prototype. The form editor only saves the properties that +this configuration allows. A listener can add property paths for a custom +inspector editor that does not declare its paths in the YAML configuration, +for example with `propertyPath`. + +.. _AfterFormDefinitionValidationConfigurationIsBuiltEvent-example: + +Example: Allow the form editor to save a custom property +======================================================== + +The following listener allows the form editor to save the property +`properties.my.custom.property` of the custom form element +`MyCustomElement`. A custom inspector editor sets this property without a +`propertyPath` in the YAML configuration: + +.. literalinclude:: _AfterFormDefinitionValidationConfigurationIsBuiltEvent/_CustomPropertyPathListener.php + :caption: EXT:my_extension/Classes/EventListener/CustomPropertyPathListener.php + +.. _AfterFormDefinitionValidationConfigurationIsBuiltEvent-api: + +API +=== + +.. include:: /CodeSnippets/Events/Form/AfterFormDefinitionValidationConfigurationIsBuiltEvent.rst.txt diff --git a/Documentation/ApiOverview/Events/Events/Form/AfterFormStateInitializedEvent.rst b/Documentation/ApiOverview/Events/Events/Form/AfterFormStateInitializedEvent.rst new file mode 100644 index 0000000000..d729e9b0ca --- /dev/null +++ b/Documentation/ApiOverview/Events/Events/Form/AfterFormStateInitializedEvent.rst @@ -0,0 +1,41 @@ +.. include:: /Includes.rst.txt +.. index:: Events; AfterFormStateInitializedEvent + +.. _AfterFormStateInitializedEvent: + +================================ +`AfterFormStateInitializedEvent` +================================ + +.. versionadded:: 15.0 + :changelog: feature-109811-1759230000 + + The event replaces the removed hook + :php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['afterFormStateInitialized']` + and the interface + :php:`\TYPO3\CMS\Form\Domain\Runtime\FormRuntime\Lifecycle\AfterFormStateInitializedInterface`. + +The event :php:`\TYPO3\CMS\Form\Event\AfterFormStateInitializedEvent` is +dispatched after the form runtime has restored the form state from the +request. The submitted values and the form definition are both available. +A listener can read and change the form state through `$formRuntime` and +read the request in `$request`. + +.. _AfterFormStateInitializedEvent-example: + +Example: Fill a form field from a query parameter +================================================= + +The following listener writes the query parameter `campaign` into the form +field `campaign`, unless the field already has a value. The form then sends +the campaign that the visitor came from along with the other values: + +.. literalinclude:: _AfterFormStateInitializedEvent/_CampaignFromQueryListener.php + :caption: EXT:my_extension/Classes/EventListener/CampaignFromQueryListener.php + +.. _AfterFormStateInitializedEvent-api: + +API +=== + +.. include:: /CodeSnippets/Events/Form/AfterFormStateInitializedEvent.rst.txt diff --git a/Documentation/ApiOverview/Events/Events/Form/Index.rst b/Documentation/ApiOverview/Events/Events/Form/Index.rst index 2387be0539..9aa00bfe56 100644 --- a/Documentation/ApiOverview/Events/Events/Form/Index.rst +++ b/Documentation/ApiOverview/Events/Events/Form/Index.rst @@ -9,11 +9,13 @@ Form The following list contains :ref:`PSR-14 events ` in EXT:form. -.. versionchanged:: 14.0 - All former hooks of EXT:form are now available as PSR-14 events. +.. versionchanged:: 15.0 + :changelog: breaking-109811-1759230001 - Some `Legacy hooks `_ - are still supported. + The last hooks of EXT:form, `afterFormStateInitialized` and + `buildFormDefinitionValidationConfiguration`, were replaced by + PSR-14 events. See also + `Breaking: #109849 - Removed "buildFormDefinitionValidationConfiguration" hook `_. **Contents:** diff --git a/Documentation/ApiOverview/Events/Events/Form/_AfterFormDefinitionValidationConfigurationIsBuiltEvent/_CustomPropertyPathListener.php b/Documentation/ApiOverview/Events/Events/Form/_AfterFormDefinitionValidationConfigurationIsBuiltEvent/_CustomPropertyPathListener.php new file mode 100644 index 0000000000..edc3fddb8c --- /dev/null +++ b/Documentation/ApiOverview/Events/Events/Form/_AfterFormDefinitionValidationConfigurationIsBuiltEvent/_CustomPropertyPathListener.php @@ -0,0 +1,25 @@ +getConfiguration(); + $element = $configuration['formElements']['MyCustomElement'] ?? []; + // Allow the form editor to write a property that a custom + // inspector editor sets without a "propertyPath" + $element['additionalPropertyPaths'][] = 'properties.my.custom.property'; + $configuration['formElements']['MyCustomElement'] = $element; + $event->setConfiguration($configuration); + } +} diff --git a/Documentation/ApiOverview/Events/Events/Form/_AfterFormStateInitializedEvent/_CampaignFromQueryListener.php b/Documentation/ApiOverview/Events/Events/Form/_AfterFormStateInitializedEvent/_CampaignFromQueryListener.php new file mode 100644 index 0000000000..eb7c5fa52f --- /dev/null +++ b/Documentation/ApiOverview/Events/Events/Form/_AfterFormStateInitializedEvent/_CampaignFromQueryListener.php @@ -0,0 +1,27 @@ +formRuntime->getFormState(); + if ($formState === null) { + return; + } + // Remember the campaign the visitor came from, unless already set + $campaign = $event->request->getQueryParams()['campaign'] ?? ''; + if ($campaign !== '' && $formState->getFormValue('campaign') === null) { + $formState->setFormValue('campaign', $campaign); + } + } +} diff --git a/Documentation/CodeSnippets/Events/Form/AfterFormDefinitionValidationConfigurationIsBuiltEvent.rst.txt b/Documentation/CodeSnippets/Events/Form/AfterFormDefinitionValidationConfigurationIsBuiltEvent.rst.txt new file mode 100644 index 0000000000..f184d0a4ba --- /dev/null +++ b/Documentation/CodeSnippets/Events/Form/AfterFormDefinitionValidationConfigurationIsBuiltEvent.rst.txt @@ -0,0 +1,20 @@ +.. Generated by https://github.com/TYPO3-Documentation/t3docs-codesnippets +.. php:namespace:: TYPO3\CMS\Form\Event + +.. php:class:: AfterFormDefinitionValidationConfigurationIsBuiltEvent + + Listeners to this event are able to modify the form definition validation + configuration after it has been built from the form editor setup. Use this + event to add additional writable property paths for custom form editor + inspector editor implementations that do not declare their writable + property paths through the standard YAML configuration (e.g. propertyPath). + + .. php:method:: getPrototypeName() + :returns: `string` + + .. php:method:: getConfiguration() + :returns: `array` + + .. php:method:: setConfiguration(array $configuration) + + :param $configuration: the configuration diff --git a/Documentation/CodeSnippets/Events/Form/AfterFormStateInitializedEvent.rst.txt b/Documentation/CodeSnippets/Events/Form/AfterFormStateInitializedEvent.rst.txt new file mode 100644 index 0000000000..9244f0c9ce --- /dev/null +++ b/Documentation/CodeSnippets/Events/Form/AfterFormStateInitializedEvent.rst.txt @@ -0,0 +1,13 @@ +.. Generated by https://github.com/TYPO3-Documentation/t3docs-codesnippets +.. php:namespace:: TYPO3\CMS\Form\Event + +.. php:class:: AfterFormStateInitializedEvent + + Listeners to this Event will be able to modify the form runtime after it has been initialized. + + .. php:attr:: formRuntime + :public: + + .. php:attr:: request + :readonly: + :public: From 1696508c4b2cf47e887ad042adfc4e63129c1f0c Mon Sep 17 00:00:00 2001 From: Lina Wolf <48202465+linawolf@users.noreply.github.com> Date: Tue, 20 Oct 2026 18:28:46 +0200 Subject: [PATCH 2/2] [TASK] Show the API of the form state and validation configuration events with typo3:api-class The generated code snippets are gone from main, so the new pages read the API from api.typo3.org like the other event pages. Releases: main Assisted-by: Claude Opus 5.5 Signed-off-by: Lina Wolf --- ...ionValidationConfigurationIsBuiltEvent.rst | 2 +- .../Form/AfterFormStateInitializedEvent.rst | 2 +- ...alidationConfigurationIsBuiltEvent.rst.txt | 20 ------------------- .../AfterFormStateInitializedEvent.rst.txt | 13 ------------ 4 files changed, 2 insertions(+), 35 deletions(-) delete mode 100644 Documentation/CodeSnippets/Events/Form/AfterFormDefinitionValidationConfigurationIsBuiltEvent.rst.txt delete mode 100644 Documentation/CodeSnippets/Events/Form/AfterFormStateInitializedEvent.rst.txt diff --git a/Documentation/ApiOverview/Events/Events/Form/AfterFormDefinitionValidationConfigurationIsBuiltEvent.rst b/Documentation/ApiOverview/Events/Events/Form/AfterFormDefinitionValidationConfigurationIsBuiltEvent.rst index e8ef889ed7..7d0968ea65 100644 --- a/Documentation/ApiOverview/Events/Events/Form/AfterFormDefinitionValidationConfigurationIsBuiltEvent.rst +++ b/Documentation/ApiOverview/Events/Events/Form/AfterFormDefinitionValidationConfigurationIsBuiltEvent.rst @@ -39,4 +39,4 @@ The following listener allows the form editor to save the property API === -.. include:: /CodeSnippets/Events/Form/AfterFormDefinitionValidationConfigurationIsBuiltEvent.rst.txt +.. typo3:api-class:: \TYPO3\CMS\Form\Event\AfterFormDefinitionValidationConfigurationIsBuiltEvent diff --git a/Documentation/ApiOverview/Events/Events/Form/AfterFormStateInitializedEvent.rst b/Documentation/ApiOverview/Events/Events/Form/AfterFormStateInitializedEvent.rst index d729e9b0ca..8c24a11b6c 100644 --- a/Documentation/ApiOverview/Events/Events/Form/AfterFormStateInitializedEvent.rst +++ b/Documentation/ApiOverview/Events/Events/Form/AfterFormStateInitializedEvent.rst @@ -38,4 +38,4 @@ the campaign that the visitor came from along with the other values: API === -.. include:: /CodeSnippets/Events/Form/AfterFormStateInitializedEvent.rst.txt +.. typo3:api-class:: \TYPO3\CMS\Form\Event\AfterFormStateInitializedEvent diff --git a/Documentation/CodeSnippets/Events/Form/AfterFormDefinitionValidationConfigurationIsBuiltEvent.rst.txt b/Documentation/CodeSnippets/Events/Form/AfterFormDefinitionValidationConfigurationIsBuiltEvent.rst.txt deleted file mode 100644 index f184d0a4ba..0000000000 --- a/Documentation/CodeSnippets/Events/Form/AfterFormDefinitionValidationConfigurationIsBuiltEvent.rst.txt +++ /dev/null @@ -1,20 +0,0 @@ -.. Generated by https://github.com/TYPO3-Documentation/t3docs-codesnippets -.. php:namespace:: TYPO3\CMS\Form\Event - -.. php:class:: AfterFormDefinitionValidationConfigurationIsBuiltEvent - - Listeners to this event are able to modify the form definition validation - configuration after it has been built from the form editor setup. Use this - event to add additional writable property paths for custom form editor - inspector editor implementations that do not declare their writable - property paths through the standard YAML configuration (e.g. propertyPath). - - .. php:method:: getPrototypeName() - :returns: `string` - - .. php:method:: getConfiguration() - :returns: `array` - - .. php:method:: setConfiguration(array $configuration) - - :param $configuration: the configuration diff --git a/Documentation/CodeSnippets/Events/Form/AfterFormStateInitializedEvent.rst.txt b/Documentation/CodeSnippets/Events/Form/AfterFormStateInitializedEvent.rst.txt deleted file mode 100644 index 9244f0c9ce..0000000000 --- a/Documentation/CodeSnippets/Events/Form/AfterFormStateInitializedEvent.rst.txt +++ /dev/null @@ -1,13 +0,0 @@ -.. Generated by https://github.com/TYPO3-Documentation/t3docs-codesnippets -.. php:namespace:: TYPO3\CMS\Form\Event - -.. php:class:: AfterFormStateInitializedEvent - - Listeners to this Event will be able to modify the form runtime after it has been initialized. - - .. php:attr:: formRuntime - :public: - - .. php:attr:: request - :readonly: - :public: