Skip to content

Commit

Permalink
Support added for stevie-mayhew/hasoneedit module
Browse files Browse the repository at this point in the history
  • Loading branch information
dizzystuff committed Feb 22, 2022
1 parent af4667b commit 6e32bfd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Forms/MiniGridField.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\Forms\FormField;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridFieldAddNewButton;
Expand All @@ -20,6 +21,7 @@
use SilverStripe\View\Requirements;
use Symbiote\GridFieldExtensions\GridFieldAddNewMultiClass;
use Symbiote\GridFieldExtensions\GridFieldOrderableRows;
use SGN\HasOneEdit\HasOneEdit;

class MiniGridField extends FormField
{
Expand Down Expand Up @@ -71,6 +73,16 @@ public function getRelationName()
if (empty($name)) {
$name = $this->name;
}

$hasOneEditModuleExists = ModuleLoader::inst()->getManifest()
->moduleExists('stevie-mayhew/hasoneedit');
if ($hasOneEditModuleExists)
{
if (HasOneEdit::isHasOneEditField($name)) {
list($parentRelationName, $name) = HasOneEdit::getRelationNameAndField($name);
}
}

$this->extend('updateRelationName', $name);
return $name;
}
Expand Down

0 comments on commit 6e32bfd

Please sign in to comment.