BeforeFormIsDeletedEvent
New in version 14.0
The event
Before
is a more powerful replacement for the removed hook
$GLOBALS.
The event
Before
can prevent the deletion of a form and add custom logic based on the delete
action. The event is dispatched just before a form is deleted in the backend.
Setting
$prevent to
true, stops the event and no further listener is called.
See also
- The backend form editor is described in detail in the TYPO3 Form manual - Form editor.
Example
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\EventListener;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Form\Event\BeforeFormIsDeletedEvent;
#[AsEventListener(
identifier: 'my-extension/before-form-is-deleted',
)]
final readonly class MyEventListener
{
public function __invoke(BeforeFormIsDeletedEvent $event): void
{
if ($event->formPersistenceIdentifier === 'some-identifier') {
$event->preventDeletion = true;
}
}
}
API
- class BeforeFormIsDeletedEvent
-
- Fully qualified name
-
\TYPO3\
CMS\ Form\ Event\ Before Form Is Deleted Event
Listeners to this Event will be able to: - Get the form persistence identifier before a form is deleted - Stop the deletion process by setting preventDeletion to true - Add custom logic, e.g. cleanup tasks, before deletion