mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
FIX: Don't force-add view button to readonly GridField (fixes #9249)
This commit is contained in:
parent
109ac3f75f
commit
d85ff3bc44
@ -247,6 +247,7 @@ class GridField extends FormField
|
|||||||
$copy = clone $this;
|
$copy = clone $this;
|
||||||
$copy->setReadonly(true);
|
$copy->setReadonly(true);
|
||||||
$copyConfig = $copy->getConfig();
|
$copyConfig = $copy->getConfig();
|
||||||
|
$hadEditButton = $copyConfig->getComponentByType(GridFieldEditButton::class) !== null;
|
||||||
|
|
||||||
// get the whitelist for allowable readonly components
|
// get the whitelist for allowable readonly components
|
||||||
$allowedComponents = $this->getReadonlyComponents();
|
$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 the edit button has been removed, replace it with a view button
|
||||||
if (!$copyConfig->getComponentByType(GridFieldViewButton::class)) {
|
if ($hadEditButton && !$copyConfig->getComponentByType(GridFieldViewButton::class)) {
|
||||||
$copyConfig->addComponent(new GridFieldViewButton);
|
$copyConfig->addComponent(new GridFieldViewButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user