FIX: Don't force-add view button to readonly GridField (fixes #… (#9254)

FIX: Don't force-add view button to readonly GridField (fixes #9249)
This commit is contained in:
Guy Marriott 2019-09-23 10:31:25 -07:00 committed by GitHub
commit aa7c057422
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -247,6 +247,7 @@ class GridField extends FormField
$copy = clone $this;
$copy->setReadonly(true);
$copyConfig = $copy->getConfig();
$hadEditButton = $copyConfig->getComponentByType(GridFieldEditButton::class) !== null;
// get the whitelist for allowable readonly components
$allowedComponents = $this->getReadonlyComponents();
@ -257,8 +258,8 @@ class GridField extends FormField
}
}
// As the edit button may have been removed, add a view button if it doesn't have one
if (!$copyConfig->getComponentByType(GridFieldViewButton::class)) {
// If the edit button has been removed, replace it with a view button
if ($hadEditButton && !$copyConfig->getComponentByType(GridFieldViewButton::class)) {
$copyConfig->addComponent(new GridFieldViewButton);
}