public function ID()
 {
     if ($this->tabSet) {
         return $this->tabSet->ID() . '_' . $this->id;
     } else {
         return $this->id;
     }
 }
 protected function getFormFieldTabs($record, $context = [])
 {
     // Add extra tab
     $tabs = TabSet::create('Editor', $this->getFormFieldDetailsTab($record, $context), $this->getFormFieldUsageTab($record, $context), $this->getFormFieldHistoryTab($record, $context));
     // All non-admin forms are typically readonly
     switch ($this->getFormType($context)) {
         case static::TYPE_INSERT:
             $tabs->setReadonly(true);
             $tabs->unshift($this->getFormFieldAttributesTab($record, $context));
             break;
         case static::TYPE_SELECT:
             $tabs->setReadonly(true);
             break;
     }
     return $tabs;
 }
 public function getCMSFields()
 {
     $path = '/' . dirname($this->getFilename());
     $previewLink = Convert::raw2att($this->PreviewLink());
     $image = "<img src=\"{$previewLink}\" class=\"editor__thumbnail\" />";
     $link = $this->Link();
     $statusTitle = $this->getStatusTitle();
     $statusFlag = "<span class=\"editor__status-flag\">{$statusTitle}</span>";
     $content = Tab::create('Main', HeaderField::create('TitleHeader', $this->Title, 1)->addExtraClass('editor__heading'), LiteralField::create("ImageFull", $image)->addExtraClass('editor__file-preview'), TabSet::create('Editor', Tab::create('Details', TextField::create("Title", $this->fieldLabel('Title')), TextField::create("Name", $this->fieldLabel('Filename')), ReadonlyField::create("Path", _t('AssetTableField.PATH', 'Path'), ($path !== '/.' ? $path : '') . '/'), HTMLReadonlyField::create('ClickableURL', _t('AssetTableField.URL', 'URL'), sprintf('<i class="%s"></i><a href="%s" target="_blank">%s</a>', 'font-icon-link btn--icon-large form-control-static__icon', $link, $link))), Tab::create('Usage', DatetimeField::create("Created", _t('AssetTableField.CREATED', 'First uploaded'))->setReadonly(true), DatetimeField::create("LastEdited", _t('AssetTableField.LASTEDIT', 'Last changed'))->setReadonly(true))), HiddenField::create('ID', $this->ID));
     if ($dimensions = $this->getDimensions()) {
         $content->insertAfter('TitleHeader', LiteralField::create("DisplaySize", sprintf('<div class="editor__specs">%spx, %s %s</div>', $dimensions, $this->getSize(), $statusFlag)));
     } else {
         $content->insertAfter('TitleHeader', LiteralField::create('StatusFlag', $statusFlag));
     }
     $fields = FieldList::create(TabSet::create('Root', $content));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 /**
  * @todo check actual placement of fields
  */
 public function testInsertAfterWithNestedTabsets()
 {
     $FieldListA = new FieldList($tabSetA = new TabSet('TabSet_A', $tabA1 = new Tab('Tab_A1', new TextField('A_pre'), new TextField('A'), new TextField('A_post')), $tabB1 = new Tab('Tab_B1', new TextField('B'))));
     $tabSetA->insertAfter($A_insertafter = new TextField('A_insertafter'), 'A');
     $this->assertEquals($FieldListA->dataFieldByName('A_insertafter'), $A_insertafter, 'Field on toplevel tab can be inserted after');
     $this->assertEquals(0, $tabA1->fieldPosition('A_pre'));
     $this->assertEquals(1, $tabA1->fieldPosition('A'));
     $this->assertEquals(2, $tabA1->fieldPosition('A_insertafter'));
     $this->assertEquals(3, $tabA1->fieldPosition('A_post'));
     $FieldListB = new FieldList(new TabSet('TabSet_A', $tabsetB = new TabSet('TabSet_B', $tabB1 = new Tab('Tab_B1', new TextField('C')), $tabB2 = new Tab('Tab_B2', new TextField('B_pre'), new TextField('B'), new TextField('B_post')))));
     $FieldListB->insertAfter($B_insertafter = new TextField('B_insertafter'), 'B');
     $this->assertSame($FieldListB->dataFieldByName('B_insertafter'), $B_insertafter, 'Field on nested tab can be inserted after');
     $this->assertEquals(0, $tabB2->fieldPosition('B_pre'));
     $this->assertEquals(1, $tabB2->fieldPosition('B'));
     $this->assertEquals(2, $tabB2->fieldPosition('B_insertafter'));
     $this->assertEquals(3, $tabB2->fieldPosition('B_post'));
 }
 /**
  * Gets the main tabs for the file edit form
  *
  * @param File $record
  * @return TabSet
  */
 protected function getFormFieldTabs($record, $context = [])
 {
     $tabs = TabSet::create('Editor', $this->getFormFieldDetailsTab($record));
     return $tabs;
 }
 /**
  * Return the FieldList used to edit this folder in the CMS.
  * You can modify this FieldList by subclassing folder, or by creating a {@link DataExtension}
  * and implemeting updateCMSFields(FieldList $fields) on that extension.
  *
  * @return FieldList
  */
 public function getCMSFields()
 {
     // Don't show readonly path until we can implement parent folder selection,
     // it's too confusing when readonly (makes sense for files only).
     $width = (int) Image::config()->get('asset_preview_width');
     $previewLink = Convert::raw2att($this->ScaleMaxWidth($width)->getIcon());
     $image = "<img src=\"{$previewLink}\" class=\"editor__thumbnail\" />";
     $content = Tab::create('Main', HeaderField::create('TitleHeader', $this->Title, 1)->addExtraClass('editor__heading'), LiteralField::create("IconFull", $image)->addExtraClass('editor__file-preview'), TabSet::create('Editor', Tab::create('Details', TextField::create("Name", $this->fieldLabel('Filename')))), HiddenField::create('ID', $this->ID));
     $fields = FieldList::create(TabSet::create('Root', $content));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 public function getEditForm($id = null, $fields = null)
 {
     // TODO Duplicate record fetching (see parent implementation)
     if (!$id) {
         $id = $this->currentPageID();
     }
     $form = parent::getEditForm($id);
     // TODO Duplicate record fetching (see parent implementation)
     $record = $this->getRecord($id);
     if ($record && !$record->canView()) {
         return Security::permissionFailure($this);
     }
     $memberList = GridField::create('Members', false, Member::get(), $memberListConfig = GridFieldConfig_RecordEditor::create()->addComponent(new GridFieldButtonRow('after'))->addComponent(new GridFieldExportButton('buttons-after-left')))->addExtraClass("members_grid");
     if ($record && method_exists($record, 'getValidator')) {
         $validator = $record->getValidator();
     } else {
         $validator = Member::singleton()->getValidator();
     }
     /** @var GridFieldDetailForm $detailForm */
     $detailForm = $memberListConfig->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDetailForm');
     $detailForm->setValidator($validator);
     $groupList = GridField::create('Groups', false, Group::get(), GridFieldConfig_RecordEditor::create());
     /** @var GridFieldDataColumns $columns */
     $columns = $groupList->getConfig()->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');
     $columns->setDisplayFields(array('Breadcrumbs' => Group::singleton()->fieldLabel('Title')));
     $columns->setFieldFormatting(array('Breadcrumbs' => function ($val, $item) {
         /** @var Group $item */
         return Convert::raw2xml($item->getBreadcrumbs(' > '));
     }));
     $fields = new FieldList($root = new TabSet('Root', $usersTab = new Tab('Users', _t('SecurityAdmin.Users', 'Users'), new LiteralField('MembersCautionText', sprintf('<div class="alert alert-warning" role="alert">%s</div>', _t('SecurityAdmin.MemberListCaution', 'Caution: Removing members from this list will remove them from all groups and the database'))), $memberList), $groupsTab = new Tab('Groups', singleton('SilverStripe\\Security\\Group')->i18n_plural_name(), $groupList)), new HiddenField('ID', false, 0));
     // Add import capabilities. Limit to admin since the import logic can affect assigned permissions
     if (Permission::check('ADMIN')) {
         $fields->addFieldsToTab('Root.Users', array(new HeaderField('ImportUsersHeader', _t('SecurityAdmin.IMPORTUSERS', 'Import users'), 3), new LiteralField('MemberImportFormIframe', sprintf('<iframe src="%s" id="MemberImportFormIframe" width="100%%" height="330px" frameBorder="0">' . '</iframe>', $this->Link('memberimport')))));
         $fields->addFieldsToTab('Root.Groups', array(new HeaderField('ImportGroupsHeader', _t('SecurityAdmin.IMPORTGROUPS', 'Import groups'), 3), new LiteralField('GroupImportFormIframe', sprintf('<iframe src="%s" id="GroupImportFormIframe" width="100%%" height="330px" frameBorder="0">' . '</iframe>', $this->Link('groupimport')))));
     }
     // Tab nav in CMS is rendered through separate template
     $root->setTemplate('SilverStripe\\Forms\\CMSTabSet');
     // Add roles editing interface
     $rolesTab = null;
     if (Permission::check('APPLY_ROLES')) {
         $rolesField = GridField::create('Roles', false, PermissionRole::get(), GridFieldConfig_RecordEditor::create());
         $rolesTab = $fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.TABROLES', 'Roles'));
         $rolesTab->push($rolesField);
     }
     $actionParam = $this->getRequest()->param('Action');
     if ($actionParam == 'groups') {
         $groupsTab->addExtraClass('ui-state-active');
     } elseif ($actionParam == 'users') {
         $usersTab->addExtraClass('ui-state-active');
     } elseif ($actionParam == 'roles' && $rolesTab) {
         $rolesTab->addExtraClass('ui-state-active');
     }
     $actions = new FieldList();
     $form = Form::create($this, 'EditForm', $fields, $actions)->setHTMLID('Form_EditForm');
     $form->addExtraClass('cms-edit-form fill-height');
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     // Tab nav in CMS is rendered through separate template
     if ($form->Fields()->hasTabSet()) {
         $form->Fields()->findOrMakeTab('Root')->setTemplate('SilverStripe\\Forms\\CMSTabSet');
     }
     $form->addExtraClass('ss-tabset cms-tabset ' . $this->BaseCSSClasses());
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     $this->extend('updateEditForm', $form);
     return $form;
 }