Skip to content

Commit

Permalink
Merge pull request #47 from micschk/patch-3
Browse files Browse the repository at this point in the history
Making 'edit original' link conditional (only show if linked)
  • Loading branch information
wilr authored Dec 15, 2021
2 parents 314e28e + 3d164d8 commit 5d7a658
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Model/ElementVirtual.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ public function getCMSFields()
$this->beforeUpdateCMSFields(function (FieldList $fields) use ($invalid) {
$fields->removeByName('Title');

$message = sprintf(
'<p>%s</p><p><a href="%2$s" target="_blank">Click here to edit the original</a></p>',
_t(__CLASS__ . '.VirtualDescription', 'This is a virtual copy of an element.'),
$this->LinkedElement()->getEditLink()
);

if ($invalid) {
$warning = _t(
__CLASS__ . '.InvalidPublishStateWarning',
Expand All @@ -89,7 +83,15 @@ public function getCMSFields()
'LinkedElementID',
$autocomplete
);
$fields->addFieldToTab('Root.Main', LiteralField::create('Existing', $message));

if($this->LinkedElementID){
$message = sprintf(
'<p>%s</p><p><a href="%2$s" target="_blank">Click here to edit the original</a></p>',
_t(__CLASS__ . '.VirtualDescription', 'This is a virtual copy of an element.'),
$this->LinkedElement()->getEditLink()
);
$fields->addFieldToTab('Root.Main', LiteralField::create('Existing', $message));
}
});

return parent::getCMSFields();
Expand Down

0 comments on commit 5d7a658

Please sign in to comment.