如何编辑Hybris Backoffice表单?移除/禁用默认弹窗字段
修改Hybris Backoffice表单字段:隐藏或禁用「Time Created」
当然可以通过XML配置文件来调整Backoffice里的弹窗表单,不管是隐藏「Time Created」字段还是禁用它,都有对应的解决方案,下面我给你详细说明:
方法1:直接隐藏字段(推荐)
如果希望用户完全看不到「Time Created」字段,你可以在自定义extension的backoffice-config.xml文件中覆盖目标类型的编辑器区域配置,只保留你需要的字段。
具体操作步骤:
- 在你的自定义extension目录下找到
resources/backoffice/backoffice-config.xml(如果没有就新建) - 添加以下配置(针对
Title类型):
<context type="Title" component="editor-area"> <editorArea:editorArea xmlns:editorArea="http://www.hybris.com/cockpitng/component/editorArea"> <editorArea:tab name="hmc.tab.general"> <editorArea:section name="hmc.section.general"> <!-- 这里列出你需要保留的所有字段,不要包含timeCreated --> <editorArea:attribute qualifier="code"/> <editorArea:attribute qualifier="name"/> <!-- 其他你需要展示的字段... --> </editorArea:section> </editorArea:tab> </editorArea:editorArea> </context>
- 保存配置后,执行
ant clean all重新构建项目,然后重启Hybris服务器;或者在Backoffice中通过System > Configuration > Reload Configuration来刷新配置。
这样「Create New Title」表单里就不会再显示「Time Created」字段了。
方法2:禁用字段(如果无法隐藏时使用)
如果因为某些原因不能隐藏字段(比如系统强制要求保留),你可以将字段设置为只读状态,用户能看到但无法编辑:
在backoffice-config.xml中添加以下配置:
<context type="Title" component="editor-area"> <editorArea:editorArea xmlns:editorArea="http://www.hybris.com/cockpitng/component/editorArea"> <editorArea:tab name="hmc.tab.general"> <editorArea:section name="hmc.section.general"> <!-- 其他字段配置 --> <editorArea:attribute qualifier="timeCreated" readonly="true"/> </editorArea:section> </editorArea:tab> </editorArea:editorArea> </context>
同样,配置生效需要重新构建或刷新Backoffice配置。
注意事项
- 确保你的自定义extension在
extensioninfo.xml中依赖了backoffice和包含Title类型的核心extension(比如core) - 确认属性的
qualifier名称正确:「Time Created」对应的模型属性名是timeCreated(驼峰命名,UI显示的是本地化后的标签) - 不要修改Hybris官方extension的配置文件,始终在自定义extension中覆盖配置,避免升级时丢失更改
内容的提问来源于stack exchange,提问作者tony
相关产品推荐
相关产品推荐

