Skip to content

Commit

Permalink
Merge pull request #23 from chrometoasters/bugfix/file-history-form
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkleiner authored May 4, 2020
2 parents 0226bb9 + f093e35 commit fd1dd87
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/Extensions/FileFormFactoryTaxonomyExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,8 @@ public function updateFormFields(FieldList $fields, $controller, $formName, $con
$record = $context['Record'];

if (!is_a($record, Folder::class)) {

// Avoid using $fields->findOrMakeTab() so the tab "Tags" is added right after the first tab "Details"
$editorTabSet = $fields->fieldByName('Editor');
$tagsTab = Tab::create('Tags', _t(self::class . '.TagsTabTitle', 'Tags'));
$editorTabSet->insertAfter('Details', $tagsTab);
if ($formName === 'fileEditForm') {
}

$tags = TreeMultiselectField::create(
'Tags',
Expand All @@ -60,10 +57,19 @@ public function updateFormFields(FieldList $fields, $controller, $formName, $con
'<a href="/at-taxonomy-overview" target="_blank" class="at-link-external">Open \'All taxonomies\' overview</a>'
);

$fields->addFieldsToTab('Editor.Tags', [
$tags,
$taxonomiesOverviewLink,
]);
// list of fields that can be used both for the edit form as well as the history view
$atFormFields = [$tags, $taxonomiesOverviewLink];

if ($formName === 'fileEditForm') {
// Avoid using $fields->findOrMakeTab() so the tab "Tags" is added right after the first tab "Details"
$editorTabSet = $fields->fieldByName('Editor');
$tagsTab = Tab::create('Tags', _t(self::class . '.TagsTabTitle', 'Tags'));
$editorTabSet->insertAfter('Details', $tagsTab);

$tagsTab->getChildren()->merge($atFormFields);
} else {
$fields->merge($atFormFields);
}
}
}
}
Expand Down

0 comments on commit fd1dd87

Please sign in to comment.