Breaking: #96158 - Remove support for inline JavaScript in fieldChangeFunc¶
See forge#96158
Description¶
Custom FormEngine
nodes allow to use internal property fieldChangeFunc
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 fieldChangeFunc
items have to
implement \TYPO3\CMS\Backend\Form\Behavior\OnFieldChangeInterface
which allows to declare the behavior in a structured way.
Impact¶
Assigning scalar values to fieldChangeFunc
items - without using
\TYPO3\CMS\Backend\Form\Behavior\OnFieldChangeInterface
- is not
supported anymore and will lead to PHP type errors.
Affected Installations¶
Installations implementing custom FormEngine
components (wizards, nodes,
render-types, ...) that provide inline JavaScript using fieldChangeFunc
.
// 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\CMS\Backend\Form\Behavior\OnFieldChangeInterface
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 OnFieldChangeInterface
instances...
// examples
$this->data['parameterArray']['fieldChangeFunc']['example'] = new AlertOnFieldChange('demo');
$parameterArray['fieldChangeFunc']['example'] = new AlertOnFieldChange('demo');