diff --git a/app/Abstracts/View/Components/DocumentForm.php b/app/Abstracts/View/Components/DocumentForm.php index 5f38dccb3..16cd00f9a 100644 --- a/app/Abstracts/View/Components/DocumentForm.php +++ b/app/Abstracts/View/Components/DocumentForm.php @@ -49,6 +49,9 @@ abstract class DocumentForm extends Base /** @var string */ public $routeUpdate; + /** @var string */ + public $routeCancel; + /** @var string */ public $formId; @@ -195,7 +198,7 @@ abstract class DocumentForm extends Base bool $hideLogo = false, bool $hideDocumentTitle = false, bool $hideDocumentSubheading = false, bool $hideCompanyEdit = false, /** Company Component End */ /** Content Component Start */ - string $routeStore = '', string $routeUpdate = '', string $formId = 'document', string $formSubmit = 'onSubmit', + string $routeStore = '', string $routeUpdate = '', string $formId = 'document', string $formSubmit = 'onSubmit', string $routeCancel = '', bool $hideCompany = false, bool $hideAdvanced = false, bool $hideFooter = false, bool $hideButtons = false, /** Content Component End */ /** Metadata Component Start */ @@ -232,6 +235,7 @@ abstract class DocumentForm extends Base /** Content Component Start */ $this->routeStore = $this->getRouteStore($type, $routeStore); $this->routeUpdate = $this->getRouteUpdate($type, $routeUpdate, $document); + $this->routeCancel = $this->getRouteCancel($type, $routeCancel); $this->formId = $formId; $this->formSubmit = $formSubmit; @@ -322,6 +326,21 @@ abstract class DocumentForm extends Base return 'invoices.update'; } + protected function getRouteCancel($type, $routeCancel) + { + if (!empty($routeCancel)) { + return $routeCancel; + } + + $route = $this->getRouteFromConfig($type, 'index'); + + if (!empty($route)) { + return $route; + } + + return 'invoices.index'; + } + protected function getContacts($type, $contacts) { if (!empty($contacts)) { diff --git a/resources/views/components/documents/form/buttons.blade.php b/resources/views/components/documents/form/buttons.blade.php index a87f137d3..56da609e3 100644 --- a/resources/views/components/documents/form/buttons.blade.php +++ b/resources/views/components/documents/form/buttons.blade.php @@ -2,7 +2,7 @@