根据当前页面模板在表单选项卡上显示字段

Display field on form tab based on current page template

如果模板不在类别中,我试图在 Kentico 的表单选项卡中隐藏字段。我在能见度条件下尝试了以下方法:

CurrentDocument.DocumentPageTemplate.PageTemplateCategory.DisplayName=="foo"

用 EditedObject 替换 CurrentDocument

EditedObject.DocumentPageTemplate.PageTemplateCategory.CategoryDisplayName="foo"

如果类别等于 foo 它将可见,否则不可见

在 Kentico UI 中工作并设置字段可见性时,始终使用 EditedObject 对象与 CurrentDocument 对象。 CurrentObject 对象仅在实际页面运行期间使用,从不在表单选项卡上使用。 EditedObject 将在页面类型的表单选项卡以及任何 Kentico UI 页面中使用。

因此,在您的情况下,将 CurrentDocument 替换为 EditedObject 以获得正确的对象。