bca2cc54cc86aad431f88414da3dc34d606ce9d2
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Documentation / Changelog / master / Important-80301-ExtFormCleanupAndCallbackMigration.rst
1 .. include:: ../../Includes.txt
2
3 ===========================================================
4 Important: #80301 - EXT:form - Cleanup / callback migration
5 ===========================================================
6
7 See :issue:`80301`
8
9 Description
10 ===========
11
12 The callback 'onBuildingFinished' is deprecated and will be removed in TYPO3 v9.
13 --------------------------------------------------------------------------------
14
15 Use the new signal slot 'onBuildingFinished' instead.
16
17 Connect to the signal:
18
19 .. code-block:: php
20
21     \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect(
22         \TYPO3\CMS\Form\Domain\Runtime\FormRuntime::class,
23         'onBuildingFinished',
24         \VENDOR\YourNamespace\YourClass::class,
25         'onBuildingFinished'
26     );
27
28 Use the signal:
29
30 .. code-block:: php
31
32     /**
33      * @param \TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface $renderable
34      * @return void
35      */
36     public function onBuildingFinished(\TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface $renderable)
37     {
38     }
39
40
41 This signal will be dispatched for each renderable.
42
43
44 The callback 'beforeRendering' is deprecated and will be removed in TYPO3 v9.
45 -----------------------------------------------------------------------------
46
47 Use the new signal slot 'beforeRendering' instead.
48
49 Connect to the signal:
50
51 .. code-block:: php
52
53     \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect(
54         \TYPO3\CMS\Form\Domain\Runtime\FormRuntime::class,
55         'beforeRendering',
56         \VENDOR\YourNamespace\YourClass::class,
57         'beforeRendering'
58     );
59
60 Use the signal:
61
62 .. code-block:: php
63
64     /**
65      * @param \TYPO3\CMS\Form\Domain\Runtime\FormRuntime $formRuntime
66      * @param \TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface $renderable
67      * @return void
68      */
69     public function beforeRendering(\TYPO3\CMS\Form\Domain\Runtime\FormRuntime $formRuntime, \TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface $renderable)
70     {
71     }
72
73
74 This signal will be dispatched for each renderable.
75
76
77 The callback 'onSubmit' is deprecated and will be removed in TYPO3 v9.
78 ----------------------------------------------------------------------
79
80 Use the new signal slot 'onSubmit' instead.
81
82 Connect to the signal:
83
84 .. code-block:: php
85
86     \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect(
87         \TYPO3\CMS\Form\Domain\Runtime\FormRuntime::class,
88         'onSubmit',
89         \VENDOR\YourNamespace\YourClass::class,
90         'onSubmit'
91     );
92
93 Use the signal:
94
95 .. code-block:: php
96
97     /**
98      * @param \TYPO3\CMS\Form\Domain\Runtime\FormRuntime $formRuntime
99      * @param \TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface $renderable
100      * @param mixed &$elementValue submitted value of the element *before post processing*
101      * @param array $requestArguments submitted raw request values
102      * @return void
103      */
104     public function onSubmit(\TYPO3\CMS\Form\Domain\Runtime\FormRuntime $formRuntime, \TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface $renderable, &$elementValue, array $requestArguments = [])
105     {
106     }
107
108
109 This signal will be dispatched for each renderable.
110
111
112 The callback 'initializeFormElement' dispatches the 'initializeFormElement' signal.
113 -----------------------------------------------------------------------------------
114
115 Connect to the signal:
116
117 .. code-block:: php
118
119     \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect(
120         \TYPO3\CMS\Form\Domain\Model\Renderable\AbstractRenderable::class,
121         'initializeFormElement',
122         \VENDOR\YourNamespace\YourClass::class,
123         'initializeFormElement'
124     );
125
126 Use the signal:
127
128 .. code-block:: php
129
130     /**
131      * @param \TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface $renderable
132      * @return void
133      */
134     public function initializeFormElement(\TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface $renderable)
135     {
136     }
137
138
139 This enables you to override the 'initializeFormElement' method within your custom implementation class.
140 If you do not call the parents 'initializeFormElement' then no signal will be thrown.
141 Furthermore, you can connect to the signal and initialize the generic form elements without defining a
142 custom implementaion to access the 'initializeFormElement' method.
143 You only need a class which connects to this signal. Then detect the form element you wish to initialize.
144 This saves you a lot of configuration!
145
146
147 The form manager dispatches the 'beforeFormCreate' signal.
148 ----------------------------------------------------------
149
150 Connect to the signal:
151
152 .. code-block:: php
153
154     \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect(
155         \TYPO3\CMS\Form\Controller\FormManagerController::class,
156         'beforeFormCreate',
157         \VENDOR\YourNamespace\YourClass::class,
158         'beforeFormCreate'
159     );
160
161 Use the signal:
162
163 .. code-block:: php
164
165     /**
166      * @string $formPersistenceIdentifier
167      * @array $formDefinition
168      * @return void
169      */
170     public function beforeFormCreate(string $formPersistenceIdentifier, array &$formDefinition)
171     {
172     }
173
174
175 The form manager dispatches the 'beforeFormDuplicate' signal.
176 -------------------------------------------------------------
177
178 Connect to the signal:
179
180 .. code-block:: php
181
182     \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect(
183         \TYPO3\CMS\Form\Controller\FormManagerController::class,
184         'beforeFormDuplicate',
185         \VENDOR\YourNamespace\YourClass::class,
186         'beforeFormDuplicate'
187     );
188
189 Use the signal:
190
191 .. code-block:: php
192
193     /**
194      * @string $formPersistenceIdentifier
195      * @array $formDefinition
196      * @return void
197      */
198     public function beforeFormDuplicate(string $formPersistenceIdentifier, array &$formDefinition)
199     {
200     }
201
202
203 The form manager dispatches the 'beforeFormDelete' signal.
204 ----------------------------------------------------------
205
206 Connect to the signal:
207
208 .. code-block:: php
209
210     \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect(
211         \TYPO3\CMS\Form\Controller\FormManagerController::class,
212         'beforeFormDelete',
213         \VENDOR\YourNamespace\YourClass::class,
214         'beforeFormDelete'
215     );
216
217 Use the signal:
218
219 .. code-block:: php
220
221     /**
222      * @string $formPersistenceIdentifier
223      * @return void
224      */
225     public function beforeFormDelete(string $formPersistenceIdentifier)
226     {
227     }
228
229 The form editor dispatches the 'beforeFormSave' signal.
230 -------------------------------------------------------
231
232 Connect to the signal:
233
234 .. code-block:: php
235
236     \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect(
237         \TYPO3\CMS\Form\Controller\FormEditorController::class,
238         'beforeFormSave',
239         \VENDOR\YourNamespace\YourClass::class,
240         'beforeFormSave'
241     );
242
243 Use the signal:
244
245 .. code-block:: php
246
247     /**
248      * @string $formPersistenceIdentifier
249      * @array $formDefinition
250      * @return void
251      */
252     public function beforeFormSave(string $formPersistenceIdentifier, array &$formDefinition)
253     {
254     }
255
256
257 New form element property: properties.fluidAdditionalAttributes
258 ---------------------------------------------------------------
259
260 To deal with fluid ViewHelpers 'additionalAttributes' it is necessary to introduce a new configuration scope "properties.fluidAdditionalAttributes" for each form element.
261 This configuration property will be used to fill the fluid ViewHelper property "additionalAttributes".
262
263
264 .. index:: Frontend, Backend, ext:form