diff --git a/Documentation/ApiOverview/Events/Events/Form/BeforeFormIsDeletedEvent.rst b/Documentation/ApiOverview/Events/Events/Form/BeforeFormIsDeletedEvent.rst new file mode 100644 index 0000000000..092de7944c --- /dev/null +++ b/Documentation/ApiOverview/Events/Events/Form/BeforeFormIsDeletedEvent.rst @@ -0,0 +1,40 @@ +.. include:: /Includes.rst.txt +.. index:: Events; BeforeFormIsDeletedEvent + +.. _BeforeFormIsDeletedEvent: + +======================== +BeforeFormIsDeletedEvent +======================== + +.. versionadded:: 14.0 + The event :php-short:`TYPO3\CMS\Form\Event\BeforeFormIsDeletedEvent` + is a more powerful replacement for the removed hook + :php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeFormDelete']`. + +The event :php-short:`TYPO3\CMS\Form\Event\BeforeFormIsDeletedEvent` +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 :php:`$preventDeletion` to +:php:`true`, stops the event and no further listener is called. + +.. seealso:: + * The backend form editor is described in detail in the `TYPO3 Form manual + - Form editor `_. + +.. _BeforeFormIsDeletedEvent-example: + +Example +======= + +.. literalinclude:: _BeforeFormIsDeletedEvent/_MyEventListener.php + :language: php + :caption: EXT:my_extension/Classes/EventListener/MyEventListener.php + +.. _BeforeFormIsDeletedEvent-api: + +API +=== + +.. include:: /CodeSnippets/Events/Form/BeforeFormIsDeletedEvent.rst.txt diff --git a/Documentation/ApiOverview/Events/Events/Form/_BeforeFormIsDeletedEvent/_MyEventListener.php b/Documentation/ApiOverview/Events/Events/Form/_BeforeFormIsDeletedEvent/_MyEventListener.php new file mode 100644 index 0000000000..64943ecab6 --- /dev/null +++ b/Documentation/ApiOverview/Events/Events/Form/_BeforeFormIsDeletedEvent/_MyEventListener.php @@ -0,0 +1,21 @@ +formPersistenceIdentifier === 'some-identifier') { + $event->preventDeletion = true; + } + } +} diff --git a/Documentation/CodeSnippets/Config/Api/Events/EventsForm.php b/Documentation/CodeSnippets/Config/Api/Events/EventsForm.php index bf191e1162..e50722b566 100644 --- a/Documentation/CodeSnippets/Config/Api/Events/EventsForm.php +++ b/Documentation/CodeSnippets/Config/Api/Events/EventsForm.php @@ -19,6 +19,12 @@ 'targetFileName' => 'CodeSnippets/Events/Form/BeforeFormIsCreatedEvent.rst.txt', 'withCode' => false, ], + [ + 'action' => 'createPhpClassDocs', + 'class' => \TYPO3\CMS\Form\Event\BeforeFormIsDeletedEvent::class, + 'targetFileName' => 'CodeSnippets/Events/Form/BeforeFormIsDeletedEvent.rst.txt', + 'withCode' => false, + ], [ 'action' => 'createPhpClassDocs', 'class' => \TYPO3\CMS\Form\Event\BeforeRenderableIsAddedToFormEvent::class, diff --git a/Documentation/CodeSnippets/Events/Form/BeforeFormIsDeletedEvent.rst.txt b/Documentation/CodeSnippets/Events/Form/BeforeFormIsDeletedEvent.rst.txt new file mode 100644 index 0000000000..771c1bc79b --- /dev/null +++ b/Documentation/CodeSnippets/Events/Form/BeforeFormIsDeletedEvent.rst.txt @@ -0,0 +1,15 @@ +.. Generated by https://github.com/TYPO3-Documentation/t3docs-codesnippets +.. php:namespace:: TYPO3\CMS\Form\Event + +.. php:class:: BeforeFormIsDeletedEvent + + Listeners to this event will be able to prevent deletion of a form and/or + add custom logic. + + .. php:attr:: formPersistenceIdentifier + :readonly: + :public: + + .. php:attr:: preventDeletion + :public: + :returns: `bool`