#106921Inline JS no longer available in custom eval
Description
In T3 13, returnFieldJS() function returning JS in text format is no longer possible. here
https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.4/Deprecation-100587-DeprecateFormEngineAdditionalJavaScriptPostAndCustomEvalInlineJavaScript.html#example
Documentation needs updating, here
https://docs.typo3.org/m/typo3/reference-tca/13.4/en-us/ColumnsConfig/Type/Input/#columns-input-eval-custom
( details in attached screenshot )
============================================================================
*Adding an example might be helpful (it evaluates a double to 5 decimal places):*
myextkey/Configuration/JavaScriptModules.php
return [
'dependencies' => [],
'tags' => [],
'imports' => [
'@pad/myextkey/' => [
'path' => 'EXT:myextkey/Resources/Public/JavaScript/',
],
],
];
myextkey/Classes/TcaEvaluation/Double5.php
namespace PAD\Myextkey\TcaEvaluation;
use TYPO3\CMS\Core\Page\JavaScriptModuleInstruction;
/**
* Double5 TCA evaluation function class
* Evaluates and formats a 5-decimals float value
*/
class Double5
{
/**
* JavaScript code for client side validation/evaluation
*
* @param none
* @return JavaScriptModuleInstruction
*/
public function returnFieldJS(): JavaScriptModuleInstruction
{
return JavaScriptModuleInstruction::create('@pad/myextkey/Backend/FormEngine/TcaEvaluation/Double5Evaluation.js', 'Double5Evaluation');
}
/**
* Server-side validation/evaluation on saving the record
*
* @param string $value The field value to be evaluated
* @param string $is_in The "is_in" value of the field configuration from TCA
* @param bool $set Boolean defining if the value is written to the database or not.
* @return float Evaluated field value
*/
public function evaluateFieldValue($value, $is_in, &$set): float
{
$value = floatval($value);
if (is_float($value)) {
$value = round($value, 5);
} else {
$value = 0.00000;
}
return $value;
}
/**
* Server-side validation/evaluation on opening the record
*
* @param array $parameters Array with key 'value' containing the field value from the database
* @return string Evaluated field value
*/
public function deevaluateFieldValue(array $parameters): string
{
$value = floatval($parameters['value']);
return number_format($value, 5);
}
}
myextkey/Resources/Public/JavaScript/Backend/FormEngine/TcaEvaluation/Double5Evaluation.js
import FormEngineValidation from '@typo3/backend/form-engine-validation.js';
export class Double5Evaluation {
static registerCustomEvaluation(name) {
FormEngineValidation.registerCustomEvaluation(name, Double5Evaluation.double5Validation);
}
static double5Validation(value) {
value = isNaN(parseFloat(value)) ? 0 : parseFloat(value);
value = value.toFixed(5);
return value.toString();
}
}Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Files 1
History 2
-
Garvin Hicking commented and changed status
NewNeeds Feedback <span data-processor="relativetime" data-value="2025-06-22T08:11:47+00:00" > 06/22/25, 08:11 </span> -
Garvin Hicking commented and changed status
Needs FeedbackClosed <span data-processor="relativetime" data-value="2025-11-11T12:33:45+00:00" > 11/11/25, 12:33 </span>I’ve created an issue here: https://github.com/TYPO3-Documentation/TYPO3CMS-Reference-TCA/issues/1349
If you would like to add your example there as a PR or so, that would be much appreciated.
Thanks so much for the report. Issues for the documentation like the TCA Reference are actually maintained in github. Could you maybe use the “report an issue” functionality on the docs page to report the issue there? That would be great, otherwise I can do that next week for you.
Maybe if you like you can even “edit this on github” to propose the actual change, since you already showed much of this. Then the change would also be attributed to you :-)