[!!!][TASK] Remove deprecated code from TableController
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Documentation / Changelog / 9.5 / Deprecation-86163-TCATypeuserWithoutRenderType.rst
1 .. include:: ../../Includes.txt
2
3 ========================================================
4 Deprecation: #86163 - TCA type="user" without renderType
5 ========================================================
6
7 See :issue:`86163`
8
9 Description
10 ===========
11
12 The following :php:`TCA` properties on :php:`type="user"` config types have been marked as deprecated and
13 should not be used any longer:
14
15 * :php:`userFunc`
16 * :php:`parameters`
17 * :php:`noTableWrapping`
18
19
20 Impact
21 ======
22
23 This especially means that :php:`userFunc` should not be used any longer on :php:`TCA` fields
24 registered as config type :php:`user`. Those can be substituted with a custom :php:`renderType`
25 since TYPO3 v7. See example below for more details.
26
27
28 Affected Installations
29 ======================
30
31 Instances are affected if an extension registers a :php:`type=user` :php:`TCA` config type with a
32 custom :php:`userFunc`. If a field uses the :php:`userFunc` property, a PHP :php:`E_USER_DEPRECATED`
33 error is triggered during rendering.
34
35
36 Migration
37 =========
38
39 :php:`userFunc` implementations can switch to use a custom :php:`renderType` as outlined
40 in the :ref:`FormEngine documentation <t3coreapi:FormEngine-Rendering-NodeFactory>`. The TYPO3 core
41 did that for example with the `is_public` field of table `sys_file_storge` in patch 58141_.
42
43 To switch from a :php:`userFunc` implementation to a :php:`renderType`, an extension typically has
44 to register an own element node in :file:`ext_localconf.php`. Then change the user function to a class
45 that extends :php:`AbstractFormElement` where method :php:`render()` returns an array as defined
46 in helper method :php:`initializeResultArray`. The `HTML` created by the former user function should be
47 returned in :php:`$resultArray['html']`, parameters like the `tableName` can be found in :php:`$this->data`.
48
49 Note the `renderType` variant can additionally load custom `JavaScript` and `CSS` using further parts of the
50 result array, typically :php:`requireJsModules` and :php:`stylesheetFiles`. Arguments to the element
51 can be defined by using any property within the `config` section, it is up to the specific `renderType` to
52 do this, using `parameters` as property key is probably a good idea, though.
53
54 As example, imagine a :php:`TCA` user element has been defined like this in the `columns` section::
55
56 'myMapElement' = [
57 'label' => 'My map element'
58 'config' => [
59 'type' => 'user',
60 'userFunc' => 'Vendor\Extension\Tca\UserFunc\MyMap->render',
61 'parameters' => [
62 'useOpenStreetMap' => true,
63 ],
64 ],
65 ],
66
67 This should be adapted to a registered node element class::
68
69 // Register a node in ext_localconf.php
70 $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][<unix timestamp of "now">] = [
71 'nodeName' => 'customMapElement',
72 'priority' => 40,
73 'class' => \Vendor\Extension\Form\Element\CustomMapElement::class,
74 ];
75
76 With a `TCA` registration like this to delegate the element rendering to the registered class::
77
78 'myMapElement' = [
79 'label' => 'My map element'
80 'config' => [
81 'type' => 'user',
82 'renderType' => 'customMapElement',
83 'parameters' => [
84 'useOpenStreetMap' => true,
85 ],
86 ],
87 ],
88
89 And a class implementation that extends :php:`AbstractFormElement`::
90
91 <?php
92 declare(strict_types = 1);
93 namespace Vendor\Extension\Form\Element;
94
95 use TYPO3\CMS\Backend\Form\Element\AbstractFormElement;
96
97 class CustomMapElement extends AbstractFormElement
98 {
99 public function render()
100 {
101 // Custom TCA properties and other data can be found in $this->data, for example the above
102 // parameters are available in $this->data['parameterArray']['fieldConf']['config']['parameters']
103 $result = $this->initializeResultArray();
104 $result['html'] = 'my map content';
105 return $result;
106 }
107 }
108
109 .. _58141: https://review.typo3.org/#/c/58141/
110
111 .. index:: Backend, TCA, NotScanned