问题描述
基本上我试图阻止 BE 用户输入错误的内容.Thatfore我使用外部评估类(https://docs.typo3.org/typo3cms/TCAReference/8-dev/ColumnsConfig/Type/Input.html).
Basically I try to prevent the BE user to input something wrong. Thatfore i use an external evaluation class (https://docs.typo3.org/typo3cms/TCAReference/8-dev/ColumnsConfig/Type/Input.html).
现在我的问题是:我实现的函数更改了输入并设置了属性的更改
Now my problem is: The function i implemented changes the input and sets the change for the property
public function evaluateFieldValue($value, $is_in, &$set)
{
if(...){
$value = 'Wrong input';
}
return $value;
}
但这不是我的目标.我希望 BE 用户在保存记录时获得错误消息窗口(如错误输入").我该怎么做?
but that's not what i'm aiming for. I want the BE user to get an error message window (like 'wrong input') on saving the record. How do i do that?
推荐答案
我会给出一个入口路径,而不是一个完整的解决方案.
I will give an entry path, not a full solution.
ext_localconf.php
$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
$signalSlotDispatcher->connect(
'TYPO3\CMS\Backend\Controller\EditDocumentController', 'initAfter',
'YourVendor\YourExtension\Hooks\Backend\EditDocSlot', 'initAfter');
YourVendor\YourExtension\Hooks\Backend\EditDocSlot.php
namespace YourVendor\YourExtension\Hooks\Backend;
use TYPO3\CMS\Backend\Controller\EditDocumentController;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
class EditDocSlot
{
/**
*
* @param EditDocumentController $ref
*/
public function initAfter(EditDocumentController $ref)
{
/** @var PageRenderer $pageRenderer */
$pageRenderer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRenderer::class);
$pageRenderer->addJsFile(ExtensionManagementUtility::extRelPath('your_extension') . 'Resources/Public/JavaScript/FormEngineValidation.js');
}
}
your_extension/Resources/Public/JavaScript/FormEngineValidation.js
require(['jquery', "TYPO3/CMS/Backend/FormEngineValidation"], function ($, FormEngineValidation) {
// extend FormEngineValidation
// check FormEngineValidation.processValue and
// check FormEngineValidation.validateField
// and create a new eval ???!!! :)
});
一些 javascript 补丁信息http://me.dt.in.th/page/JavaScript-override/
Some javascript patching infohttp://me.dt.in.th/page/JavaScript-override/
这篇关于Typo3 扩展:防止 BE 用户在字段中进行不需要的输入时保存记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!