Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/Controllers/LinkFieldController.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ private function createLinkForm(Link $link, string $operation, bool $excludeLink
// Make readonly if fail can check
if ($operation === 'create' && !$link->canCreate()
|| $operation === 'edit' && !$link->canEdit()
|| $this->getFieldIsReadonlyOrDisabled()
|| $this->getFieldIsReadonlyOrDisabled($owner, $ownerRelation)
|| $this->getRequest()->getVar('inHistoryViewer')
) {
$form->makeReadonly();
Expand All @@ -383,13 +383,10 @@ private function createLinkForm(Link $link, string $operation, bool $excludeLink
/**
* Get if the relevant LinkField is readonly or disabled
*/
private function getFieldIsReadonlyOrDisabled(): bool
private function getFieldIsReadonlyOrDisabled(DataObject $owner, string $ownerRelation): bool
{
$ownerClass = $this->getOwnerClassFromRequest();
$ownerRelation = $this->getOwnerRelationFromRequest();

/** @var LinkField|MultiLinkField $field */
$field = Injector::inst()->get($ownerClass)->getCMSFields()->dataFieldByName($ownerRelation);
$field = $owner->getCMSFields()->dataFieldByName($ownerRelation);
if (!$field) {
return false;
}
Expand Down