Skip to content

Commit

Permalink
Merge pull request #111 from eminiarts/nova-3.12-fix
Browse files Browse the repository at this point in the history
Fixed TabsOnEdit not working on Nova 3.12
  • Loading branch information
RVxLab authored Oct 10, 2020
2 parents 8a61797 + a600ce9 commit 8b4e778
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion src/TabsOnEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Laravel\Nova\Fields\FieldCollection;
use Laravel\Nova\Panel;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Resource;

trait TabsOnEdit
{
Expand Down Expand Up @@ -138,7 +139,7 @@ public function updateFields(NovaRequest $request)
'Tabs' => [
'component' => 'tabs',
'fields' => $this->removeNonUpdateFields($request, $this->resolveFields($request)),
'panel' => Panel::defaultNameForUpdate($request->newResource()),
'panel' => Panel::defaultNameForUpdate($this->resolveResource($request)),
],
]
);
Expand All @@ -161,4 +162,17 @@ protected function assignToPanels($label, FieldCollection $fields)
return $field;
});
}

/**
* @param NovaRequest $request
* @return Resource
*/
private function resolveResource(NovaRequest $request)
{
if ($this instanceof Resource) {
return $this;
}

return $request->newResource();
}
}

0 comments on commit 8b4e778

Please sign in to comment.