Feature: #109811 - PSR-14 event AfterFormStateInitializedEvent
See forge#109811
Description
A new PSR-14 event
\TYPO3\
has been introduced. It serves as an improved replacement for the now
removed hook
$GLOBALS.
The new event is dispatched by
Form after the
Form
has been restored from the request. At this point both the form state
(submitted values) and the static form definition are available, which makes
it particularly suitable for enriching components that need runtime data (e.g.
configuring property mapping for file uploads).
The event provides the following public properties:
$form: The form runtime object (read-only).Runtime $request: The current request (read-only).
Example
An example event listener could look like this:
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Form\Event\AfterFormStateInitializedEvent;
#[AsEventListener(identifier: 'my-extension/after-form-state-initialized')]
final readonly class MyAfterFormStateInitializedEventListener
{
public function __invoke(AfterFormStateInitializedEvent $event): void
{
// Access $event->formRuntime->getFormState() here
}
}
Impact
With the new
After,
it is now possible to react to the form state being fully initialized using the
standard PSR-14 event listener mechanism.