diff --git a/README.md b/README.md index 91fdc0b..a2efba8 100644 --- a/README.md +++ b/README.md @@ -245,6 +245,13 @@ public static function getBreadcrumbs(Model $record, string $operation): array } ``` +### Overriding NestedCreateAction +By default a create page must be created when using a `NestedRelationManager`. You can disable this by adding the following to your `ManageRelatedRecords`. This allows you to configure the create action yourself i.e. make it a `slideOver` instead of redirecting to a new page. + +```php +public static bool $ignoreCreateTrait = false; +``` + ## Contributing Please see [CONTRIBUTING](./.github/CONTRIBUTING.md) for details. diff --git a/src/Actions/NestedCreateAction.php b/src/Actions/NestedCreateAction.php index 1095184..6748be4 100644 --- a/src/Actions/NestedCreateAction.php +++ b/src/Actions/NestedCreateAction.php @@ -9,8 +9,12 @@ trait NestedCreateAction { protected function configureCreateAction(CreateAction $action): void { - $resource = $this->getNestedResource(); + if (isset(static::$ignoreCreateTrait) && static::$ignoreCreateTrait === true) { + return; + } + $resource = $this->getNestedResource(); + /** @var Ancestor $ancestor */ $ancestor = $resource::getAncestor();