From 27c65f29380b10860e2159348d2a751a44e8e5e2 Mon Sep 17 00:00:00 2001 From: Brady Date: Fri, 1 Oct 2021 23:43:19 +0200 Subject: [PATCH 1/2] Document resource page redirects --- docs/02-resources.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/02-resources.md b/docs/02-resources.md index c81ce140dd..013dd89543 100644 --- a/docs/02-resources.md +++ b/docs/02-resources.md @@ -190,6 +190,19 @@ For further customization opportunities, you can override the static `$view` pro ```php public static $view = 'customers.list-records'; ``` +#### Form Redirect + +You may specify the redirect URL on submit for the `Create` and `Edit` page by overriding the `getRouteUrl()` method. + +In this case we set the redirect URL to the resource index route. +```php +protected function getRedirectUrl(Model $record): string +{ + return $this->getResource()::generateUrl(static::$indexRoute, [ + 'record' => $record, + ]); +} +``` #### Hooks From d4296bd7f61e526c523e13fac4445ef5bd6c580e Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Sun, 3 Oct 2021 10:11:02 +0100 Subject: [PATCH 2/2] Update 02-resources.md --- docs/02-resources.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/02-resources.md b/docs/02-resources.md index 013dd89543..a1dff60950 100644 --- a/docs/02-resources.md +++ b/docs/02-resources.md @@ -190,17 +190,17 @@ For further customization opportunities, you can override the static `$view` pro ```php public static $view = 'customers.list-records'; ``` -#### Form Redirect -You may specify the redirect URL on submit for the `Create` and `Edit` page by overriding the `getRouteUrl()` method. +#### Customizing Form Redirects + +You may specify a custom redirect URL for the Create and Edit pages by overriding the `getRedirectUrl()` method. + +For example, the Create form can redirect back to the List page when it is submitted: -In this case we set the redirect URL to the resource index route. ```php protected function getRedirectUrl(Model $record): string { - return $this->getResource()::generateUrl(static::$indexRoute, [ - 'record' => $record, - ]); + return $this->getResource()::generateUrl('index'); } ```