extjs - 如何将自定义文本添加到字段(可翻译)标签
问题描述
我有一个带有本地化字段数据的对象:
我想为我的 DataObject 自定义后端 UI,因为这是不可能的,只有一种语言需要该字段(-s)。
我知道,我如何检查 PHP 事件侦听器中的强制项,但我找不到任何信息,如何才能在仅用于德语的字段标签中添加星号。
这是我的 JS:
pimcore.registerNS('pimcore.test.plugin');
pimcore.test.plugin = Class.create(pimcore.plugin.admin, {
getClassName: function () {
return 'pimcore.test.plugin';
},
pimcoreReady: function (params,broker) {
},
initialize: function () {
pimcore.plugin.broker.registerPlugin(this);
},
postOpenObject: function (object, type) {
if (object.data.general.o_className === 'Product') {
// add an asterisk to field label
}
},
});
let PimcoreTestPlugin = new pimcore.test.plugin();
更新 1:我在 Pimcore Sources 中找到了在任何字段中添加星号(如果需要字段)的部分,但是如何扩展/覆盖它们?
pimcore.registerNS("pimcore.object.helpers.edit");
pimcore.object.helpers.edit = {
getRecursiveLayout: function (l, noteditable, context, skipLayoutChildren, onlyLayoutChildren, dataProvider, disableLazyRendering) {
...
// add asterisk to mandatory field
l.titleOriginal = l.title;
if(l.mandatory) {
l.title += ' <span style="color:red;">*</span>';
}
...
}
};
解决方案
我不知道如何使用 PimCore,但解决方案是使用数据绑定:
在现代
items: [{
xtype: 'textfield',
fieldLabel: 'Name',
bind: {required: '{isGerman}'}
}]
在经典
Ext.define('MyApp.overrides.form.field.Text', {
override: 'Ext.form.field.Text',
config: {
allowBlank: true
}
});
...
items: [{
xtype: 'textfield',
fieldLabel: 'Name',
bind: {allowBlank: '{!isGerman}'}
}]
如果 allowBlank|required 将添加星号。
- 如果为真,required 将添加星号。允许
- 如果为 false,空白将添加星号。
推荐阅读
- c - 如何以编程方式将 S/MIME 证书应用于 Outlook(Windows、C/C++)
- apache2 - 如何在 apache2 中部署 antd-admin 仪表盘?
- excel - 根据条件在给定文件夹/子文件夹中查找 xlsm 工作簿的宏,然后检查每个工作簿中的值
- c# - 试图从连接到网络上另一台 PC 的打印机上打印条形码。可以打印测试页
- node.js - VSCode调试launch.json skipFiles排除文件夹
- vue.js - 使用 axios 获取 ERR_CERT_AUTHORITY_INVALID
- python - 如何使用return语句修复函数不返回所有行
- vb.net - 将 dataGridview 中的多行插入 Microsoft Access 中的单行
- python - 为 RandomizedSearchCV 缩放 sklearn RandomForestClassifier
- c# - 在整个 C# 解决方案中应用 Visual Studio 快速操作和重构