Skip to content

Commit

Permalink
Add conditional extension providing handler for HasOneEdit compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
dizzystuff committed Apr 17, 2023
1 parent 6e32bfd commit 8de9e4c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions _config/hasoneedit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
Name: fromholdio-minigridfield-hasoneedit
Only:
moduleexists: stevie-mayhew/hasoneedit
---

Fromholdio\MiniGridField\Forms\MiniGridField:
extensions:
fioHasOneEditMiniGridField: Fromholdio\MiniGridField\Extensions\HasOneEditMiniGridFieldExtension
16 changes: 16 additions & 0 deletions src/Extensions/HasOneEditMiniGridFieldExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Fromholdio\MiniGridField\Extensions;

use SGN\HasOneEdit\HasOneEdit;
use SilverStripe\Core\Extension;

class HasOneEditMiniGridFieldExtension extends Extension
{
public function updateRelationName(&$name)
{
if (HasOneEdit::isHasOneEditField($name)) {
list($parentRelationName, $name) = HasOneEdit::getRelationNameAndField($name);
}
}
}

0 comments on commit 8de9e4c

Please sign in to comment.