Feature: #109849 - PSR-14 Event after form definition validation config built
See forge#109849
Description
A new PSR-14 event
\TYPO3\
has been introduced as a replacement for the now
removed hook
$GLOBALS.
The event is dispatched by
\TYPO3\ after the
form definition validation configuration has been built from the form editor
setup. It allows event listeners to add additional writable property paths for
custom form editor inspector editor implementations that do not declare their
writable property paths via the standard YAML configuration (e.g.
property).
The event provides the following API:
get– The prototype name for which the configuration was built.Prototype Name (): string get– The built validation configuration.Configuration (): array set– Replace the validation configuration.Configuration (array $configuration): void
Example
An example event listener that adds an additional writable property path for a custom form element type:
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Form\Event\AfterFormDefinitionValidationConfigurationIsBuiltEvent;
#[AsEventListener(
identifier: 'my-extension/after-form-definition-validation-configuration-is-built',
)]
final readonly class MyEventListener
{
public function __invoke(AfterFormDefinitionValidationConfigurationIsBuiltEvent $event): void
{
$configuration = $event->getConfiguration();
$configuration['formElements']['MyCustomElement']['additionalPropertyPaths'][]
= 'properties.my.custom.property';
$event->setConfiguration($configuration);
}
}
Impact
With the new
After,
it is now possible to extend the form definition validation configuration
using the modern PSR-14 event listener API.