diff --git a/src/Form.php b/src/Form.php index 521763d08..6c60b7317 100755 --- a/src/Form.php +++ b/src/Form.php @@ -284,7 +284,7 @@ public function __construct($repository = null, ?Closure $callback = null, Reque { $this->repository = $repository ? Admin::repository($repository) : null; $this->callback = $callback; - $this->request = $request ?: request(); + $this->request = clone ($request ?: request()); $this->builder = new Builder($this); $this->isSoftDeletes = $repository ? $this->repository->isSoftDeletes() : false; @@ -642,9 +642,11 @@ public function store(?array $data = null, $redirectTo = null) ); } + $url = $this->getRedirectUrl($id, $redirectTo); + return $this->sendResponse( $this->response() - ->redirect($this->getRedirectUrl($id, $redirectTo)) + ->redirectIf($url !== false, $url) ->success(trans('admin.save_succeeded')) ); } catch (\Throwable $e) { @@ -814,10 +816,12 @@ public function update( ); } + $url = $this->getRedirectUrl($id, $redirectTo); + return $this->sendResponse( $this->response() ->success(trans('admin.update_succeeded')) - ->redirect($this->getRedirectUrl($id, $redirectTo)) + ->redirectIf($url !== false, $url) ); } catch (\Throwable $e) { $response = $this->handleException($e); @@ -932,7 +936,7 @@ public function getRedirectUrl($key, $redirectTo = null) if ($this->request->get('after-save') == 1) { // continue editing if ($this->builder->isEditing()) { - return; + return false; } return rtrim($resourcesPath, '/')."/{$key}/edit"; diff --git a/src/Form/Builder.php b/src/Form/Builder.php index 82cd0b817..c471da75d 100755 --- a/src/Form/Builder.php +++ b/src/Form/Builder.php @@ -578,10 +578,7 @@ public function getElementId() public function hasFile() { foreach ($this->fields() as $field) { - if ( - $field instanceof UploadField - || $field instanceof Form\Field\BootstrapFile - ) { + if ($field instanceof UploadField) { return true; } }