File tree Expand file tree Collapse file tree 4 files changed +82
-0
lines changed
ApiOverview/Events/Events/Form
_BeforeFormIsDeletedEvent Expand file tree Collapse file tree 4 files changed +82
-0
lines changed Original file line number Diff line number Diff line change 1+ .. include :: /Includes.rst.txt
2+ .. index :: Events; BeforeFormIsDeletedEvent
3+
4+ .. _BeforeFormIsDeletedEvent :
5+
6+ ========================
7+ BeforeFormIsDeletedEvent
8+ ========================
9+
10+ .. versionadded :: 14.0
11+ The event :php-short: `TYPO3\C MS\F orm\E vent\B eforeFormIsDeletedEvent `
12+ is a more powerful replacement for the removed hook
13+ :php: `$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeFormDelete'] `.
14+
15+ The event :php-short: `TYPO3\C MS\F orm\E vent\B eforeFormIsDeletedEvent `
16+ can prevent the deletion of a form and add custom logic based on the delete
17+ action. The event is dispatched just before a form is deleted in the backend.
18+
19+ Setting :php: `$preventDeletion ` to
20+ :php: `true `, stops the event and no further listener is called.
21+
22+ .. seealso ::
23+ * The backend form editor is described in detail in the `TYPO3 Form manual
24+ - Form editor <https://docs.typo3.org/permalink/typo3/cms-form:apireference-formeditor> `_.
25+
26+ .. _BeforeFormIsDeletedEvent-example :
27+
28+ Example
29+ =======
30+
31+ .. literalinclude :: _BeforeFormIsDeletedEvent/_MyEventListener.php
32+ :language: php
33+ :caption: EXT:my_extension/Classes/EventListener/MyEventListener.php
34+
35+ .. _BeforeFormIsDeletedEvent-api :
36+
37+ API
38+ ===
39+
40+ .. include :: /CodeSnippets/Events/Form/BeforeFormIsDeletedEvent.rst.txt
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace MyVendor \MyExtension \EventListener ;
6+
7+ use TYPO3 \CMS \Core \Attribute \AsEventListener ;
8+ use TYPO3 \CMS \Form \Event \BeforeFormIsDeletedEvent ;
9+
10+ #[AsEventListener(
11+ identifier: 'my-extension/before-form-is-deleted ' ,
12+ )]
13+ final readonly class MyEventListener
14+ {
15+ public function __invoke (BeforeFormIsDeletedEvent $ event ): void
16+ {
17+ if ($ event ->formPersistenceIdentifier === 'some-identifier ' ) {
18+ $ event ->preventDeletion = true ;
19+ }
20+ }
21+ }
Original file line number Diff line number Diff line change 1919 'targetFileName ' => 'CodeSnippets/Events/Form/BeforeFormIsCreatedEvent.rst.txt ' ,
2020 'withCode ' => false ,
2121 ],
22+ [
23+ 'action ' => 'createPhpClassDocs ' ,
24+ 'class ' => \TYPO3 \CMS \Form \Event \BeforeFormIsDeletedEvent::class,
25+ 'targetFileName ' => 'CodeSnippets/Events/Form/BeforeFormIsDeletedEvent.rst.txt ' ,
26+ 'withCode ' => false ,
27+ ],
2228 [
2329 'action ' => 'createPhpClassDocs ' ,
2430 'class ' => \TYPO3 \CMS \Form \Event \BeforeRenderableIsAddedToFormEvent::class,
Original file line number Diff line number Diff line change 1+ .. Generated by https://github.com/TYPO3-Documentation/t3docs-codesnippets
2+ .. php :namespace :: TYPO3\CMS\Form\Event
3+
4+ .. php :class :: BeforeFormIsDeletedEvent
5+
6+ Listeners to this event will be able to prevent deletion of a form and/or
7+ add custom logic.
8+
9+ .. php :attr :: formPersistenceIdentifier
10+ :readonly:
11+ :public:
12+
13+ .. php :attr :: preventDeletion
14+ :public:
15+ :returns: `bool `
You can’t perform that action at this time.
0 commit comments