Skip to content

Commit

Permalink
If an element has linked children, remove the delete option
Browse files Browse the repository at this point in the history
  • Loading branch information
wilr committed Jun 8, 2016
1 parent 7feb56b commit e963683
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion code/ElementalGridFieldDeleteAction.php
Expand Up @@ -6,7 +6,7 @@
class ElementalGridFieldDeleteAction extends GridFieldDeleteAction {

public function getColumnContent($gridField, $record, $columnName) {
if($record instanceof ElementVirtualLinked) {
if($record instanceof ElementVirtualLinked || $record->VirtualClones()->count() > 0) {
if(!$record->canEdit()) return;

$field = GridField_FormAction::create($gridField, 'UnlinkRelation'.$record->ID, false,
Expand Down
2 changes: 2 additions & 0 deletions code/extensions/ElementPageExtension.php
Expand Up @@ -105,7 +105,9 @@ public function getAvailableTypes() {
}
}
}

if (method_exists($this->owner, 'sortElementalOptions')) {
die();
$this->owner->sortElementalOptions($list);
} else {
asort($list);
Expand Down
4 changes: 4 additions & 0 deletions code/models/ElementVirtualLinked.php
Expand Up @@ -34,6 +34,10 @@ public function getCMSFields() {
);

$fields = new FieldList(
new TabSet('Root', $main = new Tab('Main'))
);

$main->push(
new LiteralField('Existing', $message)
);

Expand Down

0 comments on commit e963683

Please sign in to comment.