通过DataExtension Silverstripe3添加Tab(add Tab via DataExtension Silverstripe3)

编程入门 行业动态 更新时间:2024-10-16 22:21:05
通过DataExtension Silverstripe3添加Tab(add Tab via DataExtension Silverstripe3)

我想知道是否可以通过DataExtension添加Tab? 传递给updateCMSFields的FieldList参数似乎将DataExtensions新字段输出到Details选项卡上。 所以我的第一次尝试是把我的菲尔兹推到那里:

public function updateCMSFields(FieldList $fields) { $secureFilesTab = $fields; $secureFilesTab->push(new HeaderField(_t('SecureFiles.GROUPACCESSTITLE', 'Group Access'))); $secureFilesTab->push(new TreeMultiselectField('GroupPermissions', _t('SecureFiles.GROUPACCESSFIELD', 'Group Access Permissions'))); }

这很好,但是当我保存一个值时,CMS会将Tree_View和List_View选项卡中的数据加载到Details选项卡上。 下面的评论中提到的是这是一个DataExtension for Folder。

然后我尝试使用FormScaffolder中的代码添加一个新标签:

public function UpdateCMSFields(FieldList $fields) { $fields->push(new TabSet('Root', $secureFilesTab = new Tab('Security'))); $secureFilesTab->setTitle(_t('SiteTree.TABSECURITY', 'Security')); }

这会将选项卡图标全部更改为Tree_View图标,并将新的DataExtension字段放在所有选项卡上。

通过DataExtension添加标签的正确方法是什么?

I was wondering if it is possible to add a Tab via a DataExtension? The FieldList argument passed to updateCMSFields appears to output a DataExtensions new fields onto the Details Tab. So my first attempt was to push my Fields there:

public function updateCMSFields(FieldList $fields) { $secureFilesTab = $fields; $secureFilesTab->push(new HeaderField(_t('SecureFiles.GROUPACCESSTITLE', 'Group Access'))); $secureFilesTab->push(new TreeMultiselectField('GroupPermissions', _t('SecureFiles.GROUPACCESSFIELD', 'Group Access Permissions'))); }

This works fine, but when I save a value, the CMS loads the data from the Tree_View and List_View tabs onto the Details Tab. Mentioned in comments below is the fact that this is a DataExtension for Folder.

I then tried using code from the FormScaffolder to add a new Tab:

public function UpdateCMSFields(FieldList $fields) { $fields->push(new TabSet('Root', $secureFilesTab = new Tab('Security'))); $secureFilesTab->setTitle(_t('SiteTree.TABSECURITY', 'Security')); }

This changes the tab icons all to the Tree_View icons and places my new DataExtension fields on all tabs.

What is the proper way to add tabs via a DataExtension?

最满意答案

您可以使用addFieldsToTab()将新字段添加到现有选项卡或新选项卡,就像在DataObjects上使用getCMSFields()时一样。

public function updateCMSFields(FieldList $fields) { if ($this->owner->ClassName != 'Folder' ){ $fields->addFieldsToTab('Root.Security', array( new HeaderField(_t('SecureFiles.GROUPACCESSTITLE', 'Group Access')), new TreeMultiselectField('GroupPermissions', _t('SecureFiles.GROUPACCESSFIELD', 'Group Access Permissions')) )); } if ($this->owner->ClassName == 'Folder' ){ $fields->push(new HeaderField(_t('IMAFOLDER', 'I am a folder'))); } }

如果找不到安全选项卡,将通过传递'Root.Security'作为第一个参数来创建。 点表示法用于创建tabset和制表符的嵌套结构。 不可能简单地推送具有相同名称(“Root”)的新tabset,因为已经存在这样的tabset。 如果您需要对选项卡进行进一步操作,可以使用$ fields-> findOrMakeTab('TabSet.Tab')访问他们的实例,即$ fields-> findOrMakeTab('Root.Content');

You can use addFieldsToTab() to add new fields to an existing tab or a new one, as you would when using getCMSFields() on DataObjects.

public function updateCMSFields(FieldList $fields) { if ($this->owner->ClassName != 'Folder' ){ $fields->addFieldsToTab('Root.Security', array( new HeaderField(_t('SecureFiles.GROUPACCESSTITLE', 'Group Access')), new TreeMultiselectField('GroupPermissions', _t('SecureFiles.GROUPACCESSFIELD', 'Group Access Permissions')) )); } if ($this->owner->ClassName == 'Folder' ){ $fields->push(new HeaderField(_t('IMAFOLDER', 'I am a folder'))); } }

The Security tab, if not found, will be created by passing 'Root.Security' as the first argument. The dot notation is used to create the nested structure of tabset and tabs. It is not possible to simple push a new tabset with the same name ("Root"), as there's already such a tabset. If you need to do further manipulations on your tabs, you can access their instance using $fields->findOrMakeTab('TabSet.Tab'), ie $fields->findOrMakeTab('Root.Content');

更多推荐

本文发布于:2023-08-05 19:50:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1437968.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:DataExtension   add   Tab

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!