Update book form so cancel URL is explicitly passed in

- Added to prevent future possibility of 'shelf' var being introduced in
scope and therefore causing a side-effect of redirect logic.
This commit is contained in:
Dan Brown 2019-10-27 16:55:05 +00:00
parent 28184c6bfc
commit 4b9618cd21
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
3 changed files with 4 additions and 13 deletions

View File

@ -28,7 +28,7 @@
<main class="content-wrap card">
<h1 class="list-heading">{{ trans('entities.books_create') }}</h1>
<form action="{{ isset($bookshelf) ? $bookshelf->getUrl('/create-book') : url('/books') }}" method="POST" enctype="multipart/form-data">
@include('books.form')
@include('books.form', ['returnLocation' => isset($bookshelf) ? $bookshelf->getUrl() : url('/books')])
</form>
</main>
</div>

View File

@ -18,7 +18,7 @@
<h1 class="list-heading">{{ trans('entities.books_edit') }}</h1>
<form action="{{ $book->getUrl() }}" method="POST" enctype="multipart/form-data">
<input type="hidden" name="_method" value="PUT">
@include('books.form', ['model' => $book])
@include('books.form', ['model' => $book, 'returnLocation' => $book->getUrl()])
</form>
</main>
</div>

View File

@ -31,20 +31,11 @@
<label for="tag-manager">{{ trans('entities.book_tags') }}</label>
</button>
<div class="collapse-content" collapsible-content>
@include('components.tag-manager', ['entity' => isset($book)?$book:null, 'entityType' => 'chapter'])
@include('components.tag-manager', ['entity' => $book ?? null, 'entityType' => 'chapter'])
</div>
</div>
<div class="form-group text-right">
<?php
if (isset($bookshelf)) {
$cancelUrl = $bookshelf->getUrl();
} else if (isset($book)) {
$cancelUrl = $book->getUrl();
} else {
$cancelUrl = '/books';
}
?>
<a href="{{ $cancelUrl }}" class="button outline">{{ trans('common.cancel') }}</a>
<a href="{{ $returnLocation }}" class="button outline">{{ trans('common.cancel') }}</a>
<button type="submit" class="button">{{ trans('entities.books_save') }}</button>
</div>