private function existingItem(News $owner, SiteConfig $siteConfig)
    {
        if (!$owner->ID) {
            $member = Member::currentUser();
            $this->field_list['Root.Main'][13] = ReadonlyField::create('Tags', $owner->fieldLabel('Tags'), _t('News.TAGAFTERID', 'Tags can be added after the item has been saved'));
            $owner->Type = 'news';
            $owner->Author = $member->FirstName . ' ' . $member->Surname;
        } else {
            if (class_exists('MultiSelectField')) {
                /** I like multiselectfield and needed a reason to commit something */
                $this->field_list['Root.Main'][13] = MultiSelectField::create('Tags', $owner->fieldLabel('Tags'), $this->owner);
            } else {
                $this->field_list['Root.Main'][13] = CheckboxSetField::create('Tags', $owner->fieldLabel('Tags'), Tag::get()->map('ID', 'Title'));
            }
            $this->field_list['Root.Main'][2] = LiteralField::create('Dummy', '<div id="Dummy" class="field readonly">
	<label class="left" for="Form_ItemEditForm_Dummy">Link</label>
	<div class="middleColumn">
	<span id="Form_ItemEditForm_Dummy" class="readonly">
		<a href="' . $owner->AbsoluteLink() . '" target="_blank">' . $owner->AbsoluteLink() . '</a>
	</span>
	</div>
	</div>'
            );
            if ($siteConfig->EnableSlideshow) {
                /** @var GridFieldConfig_RecordEditor $gridFieldConfig */
                $gridFieldConfig = GridFieldConfig_RecordEditor::create();
                $gridFieldConfig->addComponent(new GridFieldBulkUpload());
                $gridFieldConfig->addComponent(new GridFieldOrderableRows('SortOrder'));
                $gridFieldConfig->getComponentByType('GridFieldBulkUpload')->setUfSetup('setFolderName', $this->getRootFolderName($siteConfig));

                if (class_exists('GridFieldGalleryTheme')) {
                    $gridFieldConfig->addComponent(new GridFieldGalleryTheme('Image'));

                    /**
                     * as gallery theme breaks sorting with GridFieldOrderableRows
                     * let's use SortableRows as a fallback when installed
                     *
                     * @todo remove later this when gridfield extension works with gallery theme
                     */
                    if (class_exists('GridFieldSortableRows')) {
                        $gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));
                        $gridFieldConfig->removeComponentsByType('GridFieldOrderableRows');
                    }
                }

                $this->field_list['Root'][] = Tab::create(
                    'SlideshowImages', $owner->fieldLabel('SlideshowImages'), GridField::create(
                    'SlideshowImage', _t('News.IMAGES', 'Slideshow images'), $owner->SlideshowImages()
                    ->sort('SortOrder'), $gridFieldConfig)
                );
            }
        }
    }
private function existingItem(News $owner, SiteConfig $siteConfig)
    {
        if (!$owner->ID) {
            $member = Member::currentUser();
            $this->field_list['Root.Main'][13] = ReadonlyField::create('Tags', $owner->fieldLabel('Tags'), _t('News.TAGAFTERID', 'Tags can be added after the item has been saved'));
            $owner->Type = 'news';
            $owner->Author = $member->FirstName . ' ' . $member->Surname;
        } else {
            if (class_exists('MultiSelectField')) {
                /** I like multiselectfield and needed a reason to commit something */
                $this->field_list['Root.Main'][13] = MultiSelectField::create('Tags', $owner->fieldLabel('Tags'), $this->owner);
            } else {
                $this->field_list['Root.Main'][13] = CheckboxSetField::create('Tags', $owner->fieldLabel('Tags'), Tag::get()->map('ID', 'Title'));
            }
            $this->field_list['Root.Main'][2] = LiteralField::create('Dummy', '<div id="Dummy" class="field readonly">
	<label class="left" for="Form_ItemEditForm_Dummy">Link</label>
	<div class="middleColumn">
	<span id="Form_ItemEditForm_Dummy" class="readonly">
		<a href="' . $owner->AbsoluteLink() . '" target="_blank">' . $owner->AbsoluteLink() . '</a>
	</span>
	</div>
	</div>'
            );
            if ($siteConfig->EnableSlideshow) {
                /** @var GridFieldConfig_RecordEditor $gridFieldConfig */
                $gridFieldConfig = GridFieldConfig_RecordEditor::create();
                $gridFieldConfig->addComponent(new GridFieldBulkUpload());
                $gridFieldConfig->addComponent(new GridFieldOrderableRows('SortOrder'));
                $gridFieldConfig->getComponentByType('GridFieldBulkUpload')->setUfSetup('setFolderName', $this->getRootFolderName($siteConfig));

                if (class_exists('GridFieldGalleryTheme')) {
                    $gridFieldConfig->addComponent(new GridFieldGalleryTheme('Image'));

                    /**
                     * as gallery theme breaks sorting with GridFieldOrderableRows
                     * let's use SortableRows as a fallback when installed
                     *
                     * @todo remove later this when gridfield extension works with gallery theme
                     */
                    if (class_exists('GridFieldSortableRows')) {
                        $gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));
                        $gridFieldConfig->removeComponentsByType('GridFieldOrderableRows');
                    }
                }

                $this->field_list['Root'][] = Tab::create(
                    'SlideshowImages', $owner->fieldLabel('SlideshowImages'), GridField::create(
                    'SlideshowImage', _t('News.IMAGES', 'Slideshow images'), $owner->SlideshowImages()
                    ->sort('SortOrder'), $gridFieldConfig)
                );
            }
        }
    }
private function existingItem ( News $ owner , SiteConfig $ siteConfig ) { if ( ! $ owner -> ID ) { $ member = Member :: currentUser ( ) ; $ this -> field_list [ 'Root.Main' ] [ 13 ] = ReadonlyField :: create ( 'Tags' , $ owner -> fieldLabel ( 'Tags' ) , _t ( 'News.TAGAFTERID' , 'Tags can be added after the item has been saved' ) ) ; $ owner -> Type = 'news' ; $ owner -> Author = $ member -> FirstName . ' ' . $ member -> Surname ; } else { if ( class_exists ( 'MultiSelectField' ) ) { /** I like multiselectfield and needed a reason to commit something */ $ this -> field_list [ 'Root.Main' ] [ 13 ] = MultiSelectField :: create ( 'Tags' , $ owner -> fieldLabel ( 'Tags' ) , $ this -> owner ) ; } else { $ this -> field_list [ 'Root.Main' ] [ 13 ] = CheckboxSetField :: create ( 'Tags' , $ owner -> fieldLabel ( 'Tags' ) , Tag :: get ( ) -> map ( 'ID' , 'Title' ) ) ; } $ this -> field_list [ 'Root.Main' ] [ 2 ] = LiteralField :: create ( 'Dummy' , '<div id="Dummy" class="field readonly">
	<label class="left" for="Form_ItemEditForm_Dummy">Link</label>
	<div class="middleColumn">
	<span id="Form_ItemEditForm_Dummy" class="readonly">
		<a href="' . $ owner -> AbsoluteLink ( ) . '" target="_blank">' . $ owner -> AbsoluteLink ( ) . '</a>
	</span>
	</div>
	</div>' ) ; if ( $ siteConfig -> EnableSlideshow ) { /** @var GridFieldConfig_RecordEditor $gridFieldConfig */ $ gridFieldConfig = GridFieldConfig_RecordEditor :: create ( ) ; $ gridFieldConfig -> addComponent ( new GridFieldBulkUpload ( ) ) ; $ gridFieldConfig -> addComponent ( new GridFieldOrderableRows ( 'SortOrder' ) ) ; $ gridFieldConfig -> getComponentByType ( 'GridFieldBulkUpload' ) -> setUfSetup ( 'setFolderName' , $ this -> getRootFolderName ( $ siteConfig ) ) ; if ( class_exists ( 'GridFieldGalleryTheme' ) ) { $ gridFieldConfig -> addComponent ( new GridFieldGalleryTheme ( 'Image' ) ) ; /**
                     * as gallery theme breaks sorting with GridFieldOrderableRows
                     * let's use SortableRows as a fallback when installed
                     *
                     * @todo remove later this when gridfield extension works with gallery theme
                     */ if ( class_exists ( 'GridFieldSortableRows' ) ) { $ gridFieldConfig -> addComponent ( new GridFieldSortableRows ( 'SortOrder' ) ) ; $ gridFieldConfig -> removeComponentsByType ( 'GridFieldOrderableRows' ) ; } } $ this -> field_list [ 'Root' ] [ ] = Tab :: create ( 'SlideshowImages' , $ owner -> fieldLabel ( 'SlideshowImages' ) , GridField :: create ( 'SlideshowImage' , _t ( 'News.IMAGES' , 'Slideshow images' ) , $ owner -> SlideshowImages ( ) -> sort ( 'SortOrder' ) , $ gridFieldConfig ) ) ; } } }
Setup the fields that are visible ONLY when the item exists already.

@param News $owner
@param SiteConfig $siteConfig
Setup the fields that are visible ONLY when the item exists already .