Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JavaScriptModuleInstruction to custom email #1213

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Documentation/ColumnsConfig/Type/Input/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <t3coreapi:backend-javascript-es6>`.

:file:`EXT:extension/Classes/Evaluation/ExampleEvaluation.php`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -10,11 +12,17 @@ class ExampleEvaluation
/**
* JavaScript code for client side validation/evaluation
*
* @return string JavaScript code for client side validation/evaluation
* @return string|JavaScriptModuleInstruction JavaScript code for client side validation/evaluation
*/
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');
}

/**
Expand Down
Loading