【发布时间】:2021-11-17 11:59:40
【问题描述】:
我有一个带有本地化字段数据的对象:
我想为我的 DataObject 自定义后端 UI,因为这是不可能的,只有一种语言需要该字段。
我知道,如何检查 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>';
}
...
}
};
【问题讨论】: