From 29fd18c25ed18631dec340c9315abca579dfbca7 Mon Sep 17 00:00:00 2001 From: Sybille Peters Date: Tue, 21 Jan 2025 13:44:10 +0100 Subject: [PATCH] Add JavaScriptModuleInstruction to custom email --- Documentation/ColumnsConfig/Type/Input/Index.rst | 8 +++++++- .../Type/Input/_Snippets/_ExampleEvaluation.php | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Documentation/ColumnsConfig/Type/Input/Index.rst b/Documentation/ColumnsConfig/Type/Input/Index.rst index 5e44353f..ea4f3b63 100644 --- a/Documentation/ColumnsConfig/Type/Input/Index.rst +++ b/Documentation/ColumnsConfig/Type/Input/Index.rst @@ -103,7 +103,13 @@ Custom eval rules You can supply own form evaluations in an extension by creating a class with three functions, one which returns the JavaScript code for client side validation called `returnFieldJS()` and two for the server side: `deevaluateFieldValue()` called when opening the record and `evaluateFieldValue()` called for validation when -saving the record: +saving the record. + +.. hint:: + + See EXT:redirects :php:`\TYPO3\CMS\Redirects\Evaluation\SourceHost` for a + working example. For more information about adding JavaScript modules + see :ref:`ES6 in the TYPO3 Backend `. :file:`EXT:extension/Classes/Evaluation/ExampleEvaluation.php` diff --git a/Documentation/ColumnsConfig/Type/Input/_Snippets/_ExampleEvaluation.php b/Documentation/ColumnsConfig/Type/Input/_Snippets/_ExampleEvaluation.php index a87af6c4..e1c775ea 100644 --- a/Documentation/ColumnsConfig/Type/Input/_Snippets/_ExampleEvaluation.php +++ b/Documentation/ColumnsConfig/Type/Input/_Snippets/_ExampleEvaluation.php @@ -2,6 +2,8 @@ namespace MVendor\MyExtension\Evaluation; +use TYPO3\CMS\Core\Page\JavaScriptModuleInstruction; + /** * Class for field value validation/evaluation to be used in 'eval' of TCA */ @@ -14,7 +16,13 @@ class ExampleEvaluation */ public function returnFieldJS() { - return 'return value + " [added by JavaScript on field blur]";'; + // you can return JavaScript code directly: + //return 'return value + " [added by JavaScript on field blur]";'; + + // or you can use JavaScriptModuleInstruction. + // In this case you should add your JavaScript modules using + // Configuration/JavaScriptModules.php + return JavaScriptModuleInstruction::create('@myvendor/myextension/example-evaluation.js', 'FormEngineEvaluation'); } /**