Breaking: #96158 - Remove support for inline JavaScript in fieldChangeFunc
See forge#96158
Description
Custom
Form
nodes allow to use internal property field
to add or modify client-side JavaScript behavior when field values are changed.
Through TYPO3 v11 it was possible to directly use inline JavaScript that was
assigned as plain
string
type. With TYPO3 v12.0 inline JavaScript is
not supported anymore - values assigned to field
items have to
implement
\TYPO3\
which allows to declare the behavior in a structured way.
Impact
Assigning scalar values to field
items - without using
\TYPO3\
- is not
supported anymore and will lead to PHP type errors.
Affected Installations
Installations implementing custom
Form
components (wizards, nodes,
render-types, ...) that provide inline JavaScript using field
.
// examples
$this->data['parameterArray']['fieldChangeFunc']['example'] = "alert('demo');";
$parameterArray['fieldChangeFunc']['example'] = "alert('demo');";
Migration
Previous deprecation ChangeLog documentation provided migration details already. A complete and installable example is available with ext:demo_91787 as well.
The provided code examples are supposed to work with TYPO3 v11 and v12, easing
the migration path for extension maintainers. The crucial point is to use
\TYPO3\
which still
would inline JavaScript as a fallback in TYPO3 v11.
Thus, basically scalar assignments like...
// examples
$this->data['parameterArray']['fieldChangeFunc']['example'] = "alert('demo');";
$parameterArray['fieldChangeFunc']['example'] = "alert('demo');";
... have to be replaced by custom
On
instances...
// examples
$this->data['parameterArray']['fieldChangeFunc']['example'] = new AlertOnFieldChange('demo');
$parameterArray['fieldChangeFunc']['example'] = new AlertOnFieldChange('demo');