Skip to content

Commit 3071a91

Browse files
Merge branch '5.1' into 5
2 parents a00396f + abf59c2 commit 3071a91

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

src/Controllers/LinkFieldController.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ private function createLinkForm(Link $link, string $operation, bool $excludeLink
368368
// Make readonly if fail can check
369369
if ($operation === 'create' && !$link->canCreate()
370370
|| $operation === 'edit' && !$link->canEdit()
371-
|| $this->getFieldIsReadonlyOrDisabled()
371+
|| $this->getFieldIsReadonlyOrDisabled($owner, $ownerRelation)
372372
|| $this->getRequest()->getVar('inHistoryViewer')
373373
) {
374374
$form->makeReadonly();
@@ -383,13 +383,10 @@ private function createLinkForm(Link $link, string $operation, bool $excludeLink
383383
/**
384384
* Get if the relevant LinkField is readonly or disabled
385385
*/
386-
private function getFieldIsReadonlyOrDisabled(): bool
386+
private function getFieldIsReadonlyOrDisabled(DataObject $owner, string $ownerRelation): bool
387387
{
388-
$ownerClass = $this->getOwnerClassFromRequest();
389-
$ownerRelation = $this->getOwnerRelationFromRequest();
390-
391388
/** @var LinkField|MultiLinkField $field */
392-
$field = Injector::inst()->get($ownerClass)->getCMSFields()->dataFieldByName($ownerRelation);
389+
$field = $owner->getCMSFields()->dataFieldByName($ownerRelation);
393390
if (!$field) {
394391
return false;
395392
}

0 commit comments

Comments
 (0)