Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

SS 3.1 nested Dataobject / Tab appearing


Go to End


3 Posts   1173 Views

Avatar
timo

Community Member, 47 Posts

2 March 2015 at 11:00pm

Edited: 02/03/2015 11:02pm

Hi!
Ive got a Holder- Page (PublicationHolder),
a Publication- DataObject (Publication)
and a MyImage - DataObject (MyImage)

Now a strange behavior: In Publication- Dataobject appeares a extra Tab in addition. Its the Classname of That Dataobject.
Sorry for not being too clear. See a screenshot for better explanation:

To Display the DO in a new Tab i use:

$fields->addFieldToTab('Root.Galeriebilder', $slidesField);

So where does this extra Tab comming from?
How to remove it?
Thanks. timo.

My GriField on Publication -DO looks like this:

 $gridFieldConfig = GridFieldConfig_RecordEditor::create();
		$gridFieldConfig->addComponent(new GridFieldBulkManager());
		
		$gridFieldConfig->removeComponentsByType('GridFieldPageCount');
		$gridFieldConfig->removeComponentsByType('GridFieldPaginator'); // Remove default paginator
		$gridFieldConfig->addComponent(new GridFieldPaginator(20)); // Add custom paginator
		$gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder')); 
		$gridFieldConfig->removeComponentsByType('GridFieldAddNewButton'); // We only use bulk upload 
		
		$FieldBulkUpload = new GridFieldBulkUpload();
		$FieldBulkUpload->setUfSetup('setFolderName', 'Publikationen/'.$this->Title)->setUfConfig('sequentialUploads', true);
		
		$gridFieldConfig->addComponent($FieldBulkUpload);
		
		$slidesField = new GridField(
			'Galeriebild',
			'Galeriebilder',
			$this->MyImages()->sort("SortOrder"),
			$gridFieldConfig
		);
		
		$fields->addFieldToTab('Root.Galeriebilder', $slidesField); 

All Classes:

<?php
class PublicationHolder extends Page  {

	public static $db = array(
	);
	
	private static $many_many = array (
        'Publications' => 'Publication'
    );
	
	static $description = "Publikationen";
	
	static $allowed_children = 'none';
   	
	public function getCMSFields() {
	   
   		$fields = parent::getCMSFields();
		$fields->removeFieldFromTab("Root.Main","Content");
			
		$GridFieldConfig = GridFieldConfig_RecordEditor::create();
		$GridFieldConfig->addComponent(new GridFieldBulkManager());
		$GridFieldConfig->removeComponentsByType('GridFieldPaginator'); 
		$GridFieldConfig->addComponent(new GridFieldPaginator(20)); 
		
		$Gridfield = new GridField("Publikationen", "Publikationen", Publication::get()->sort('Title', 'ASC'), $GridFieldConfig); 
		$fields->addFieldToTab('Root.Publikationen', $Gridfield);
					
		return $fields;
		
	}
	
	public function Publication(){
		return Publication::get();
	}
		
}

class PublicationHolder_Controller extends Page_Controller  { 


	public function init() {
        parent::init();
	}
		
}

//********************************************************************************************

<?php
class Publication extends DataObject
{
	static $db = array (
		'SortOrder' => 'Int',
		'Title' => 'Varchar(255)',
		'SubTitle' => 'Text',
		'PublicationText' => 'HTMLText'
	);
	
	static $has_one = array (
		'Holder' => 'PublicationHolder'
	);
	
	public static $has_many = array(
		'MyImages' => 'MyImage'
	);
	
	static $summary_fields = array(
		'Title' => 'Title'
	);
	
	static $singular_name = 'Publikation';
	static $plural_name = 'Publikationen';
	
	
	
	public function getCMSFields()
	{
		
		$fields = parent::getCMSFields();
		//$fields = FieldList::create();
		
		//$fields->removeFieldFromTab('Root', 'Main');
		$fields->removeFieldFromTab("Root.Main","SortOrder");
		//$fields->removeFieldFromTab("Root.Main","ParentClass");
		//$fields->removeFieldFromTab("Root.Main","ParentID");
		$fields->removeByName('HolderID');
		//$fields->removeByName("Root_MyImages");
		
		//$fields->removeByName('PageID');
		$fields->addFieldToTab("Root.Main", new TextField('Title', 'Titel'));
		$fields->addFieldToTab("Root.Main", new TextareaField('SubTitle', 'SubTitel'));
		$fields->addFieldToTab("Root.Main", new HTMLEditorField('PublicationText', 'Inhalt'));
		
		
		
		$gridFieldConfig = GridFieldConfig_RecordEditor::create();
		$gridFieldConfig->addComponent(new GridFieldBulkManager());
		
		$gridFieldConfig->removeComponentsByType('GridFieldPageCount');
		$gridFieldConfig->removeComponentsByType('GridFieldPaginator'); // Remove default paginator
		$gridFieldConfig->addComponent(new GridFieldPaginator(20)); // Add custom paginator
		$gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder')); 
		$gridFieldConfig->removeComponentsByType('GridFieldAddNewButton'); // We only use bulk upload 
		
		$FieldBulkUpload = new GridFieldBulkUpload();
		$FieldBulkUpload->setUfSetup('setFolderName', 'Publikationen/'.$this->Title)->setUfConfig('sequentialUploads', true);
		
		$gridFieldConfig->addComponent($FieldBulkUpload);
		
		$slidesField = new GridField(
			'Galeriebild',
			'Galeriebilder',
			$this->MyImages()->sort("SortOrder"),
			$gridFieldConfig
		);
		
		$fields->addFieldToTab('Root.Galeriebilder', $slidesField);
		
		return $fields;
	}

}

//********************************************************************************************************

<?php

class MyImage extends DataObject {
	
	static $db = array (
		'SortOrder' => 'Int',
		'Title' => 'Varchar(255)',
		'Caption' => 'Varchar(255)'
	);
	
	static $has_one = array ( 
		'Page' => 'Page', // MyImage is alo used on Pages !!!!
		'Image' => 'Image',
		'Publication' => 'Publication'
	);
	
	
	
	static $singular_name = 'Bild';
	static $plural_name = 'Bilder';
	
	public function getCMSFields(){ 
  		$fields = parent::getCMSFields();
		
		$fields->removeFieldFromTab("Root.Main","PageID");
		$fields->removeFieldFromTab("Root.Main","SortOrder");
		$fields->removeFieldFromTab("Root.Main","PublicationID");

		return $fields;
	}
	
	public static $summary_fields = array( 
		'Thumbnail' => 'Bild',
		'Title' => 'Title'     
	);
  
	public function getThumbnail() { 
		return $this->Image()->SetRatioSize(40,40);
	}
}

//***********************************************************************************

<div class="cms-content-header north" style="left: 0px; top: 0px; width: 1503px; height: auto; position: absolute;">
		<div class="cms-content-header-info">
			
	<div class="cms_backlink">
		<a href="admin/pages/edit/show/6" data-icon="back" class="backlink ss-ui-button cms-panel-link ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary" role="button" aria-disabled="false"><span class="ui-button-icon-primary ui-icon btn-icon-back"></span><span class="ui-button-text">
			Zurück
		</span></a>
	</div>
	
			
			
				<div data-pjax-fragment="Breadcrumbs" class="breadcrumbs-wrapper">
	<h2 id="page-title-heading">
		
			<span class="section-icon icon icon-16 icon-cmspagescontroller"></span>
		

		
			
				<a href="admin/pages/" class="cms-panel-link crumb">Seiten</a>
				<span class="sep">/</span>
			
		
			
				<a href="admin/pages/edit/show/6" class="cms-panel-link crumb">Publikationen</a>
				<span class="sep">/</span>
			
		
			
				<span class="cms-panel-link crumb last">Masse und Macht</span>
			
		
	</h2>
</div>

						
		</div>
		
			
			<div class="cms-content-header-tabs cms-tabset-nav-primary">
				<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" role="tablist">
				
					<li class="ui-state-default ui-corner-top ui-tabs-active ui-state-active" role="tab" tabindex="0" aria-controls="Root_Main" aria-labelledby="ui-id-34" aria-selected="true"><a href="http://localhost/SS_3.1.9/admin/pages/edit/EditForm/field/Publikationen/item/1/edit#Root_Main" class="ui-tabs-anchor" role="presentation" tabindex="-1" id="ui-id-34">Hauptteil</a></li>
				
					<li class="ui-state-default ui-corner-top" role="tab" tabindex="-1" aria-controls="Root_MyImages" aria-labelledby="ui-id-35" aria-selected="false"><a href="http://localhost/SS_3.1.9/admin/pages/edit/EditForm/field/Publikationen/item/1/edit#Root_MyImages" class="ui-tabs-anchor" role="presentation" tabindex="-1" id="ui-id-35">My Images</a></li>
				
					<li class="ui-state-default ui-corner-top" role="tab" tabindex="-1" aria-controls="Root_Galeriebilder" aria-labelledby="ui-id-36" aria-selected="false"><a href="http://localhost/SS_3.1.9/admin/pages/edit/EditForm/field/Publikationen/item/1/edit#Root_Galeriebilder" class="ui-tabs-anchor" role="presentation" tabindex="-1" id="ui-id-36">Galeriebilder</a></li>
				
				</ul>
			</div>
			
		

		<!-- <div class="cms-content-search">...</div> -->
	</div>

Avatar
Pyromanik

Community Member, 419 Posts

3 March 2015 at 3:33am

Edited: 03/03/2015 3:33am

class Publication extends DataObject
public static $has_many = ['MyImages' => 'MyImage'];

It will be being scaffolded automatically probably ($fields = parent::getCMSFields();).
You'll need to manually remove the tab if you don't want it there.
Try $fields->removeByName('Root.MyImages');

Avatar
timo

Community Member, 47 Posts

3 March 2015 at 5:06am

Edited: 07/03/2015 6:35am

OK. thanks.

its :

$fields->removeFieldFromTab("Root","MyImages");

timo