Skip to content

Commit

Permalink
Update FrequentlyAskedQuestionsExtension.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Otis Wright authored Nov 21, 2016
1 parent d45ca5c commit f16a994
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions code/Extensions/FrequentlyAskedQuestionsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,29 @@ public function updateCMSFields(FieldList $fields)
->addComponent(new GridFieldAddNewButton('buttons-before-left'))
->addComponent(new GridFieldToolbarHeader())
->addComponent(new GridFieldSortableHeader())
->addComponent(new GridFieldSortableRows('SortOrder'))
->addComponent(new GridFieldOrderableRows('SortOrder'))
->addComponent($dataColumns = new GridFieldDataColumns())
->addComponent(new GridFieldEditButton())
->addComponent(new GridFieldDeleteAction())
->addComponent(new GridFieldDetailForm());

$dataColumns->setDisplayFields([
'Title' => 'Question',
'Title' => 'Question',
'Answer.Summary' => 'Answer Preview',
]);

/** @var TabSet $rootTab */
//We need to repush Metadata to ensure it is the last tab
$rootTab = $fields->fieldByName('Root');
$rootTab->push(Tab::create('FaqSegments'));
if ($rootTab->fieldByName('Metadata')) {
$metaChildren = $rootTab->fieldByName('Metadata')->getChildren();
$rootTab->removeByName('Metadata');
$rootTab->push(Tab::create('Metadata')->setChildren($metaChildren));
//We need to repush Metadata to ensure it is the last tab
$rootTab = $fields->fieldByName('Root');
if ($this->owner->exists()) {
$rootTab->push(Tab::create('FaqSegments'));
}

$GridField = GridField::create('FaqSegments', 'FAQs', $this->owner->Faqs(), $gridConfig);

$fields->addFieldToTab('Root.FaqSegments', $GridField);
if ($this->owner->exists()) {
$fields->addFieldToTab('Root.FaqSegments', $GridField);
}
$fields->removeByName('Faqs');
return $fields;
}
Expand Down

0 comments on commit f16a994

Please sign in to comment.