单击“重新提交”后,我想刷新按钮(使用浏览器刷新按钮),但不重新提交该表单
<form action="{{ route('categories.store') }}" method="POST" role="form">
{{ csrf_field() }}
<label for=" name">Category Name</label><span class="required">*</span>
<input class="form-control input_text" id="name" required placeholder="Category Name" type="text" name="name" value="{{ old('name') }}">
<label for=" slug">Category Slug</label><span class="required">*</span>
<input class="form-control slug_text" id="slug" required placeholder="Category Slug" type="text" name="slug" value="{{ old('slug') }}">
<button type="submit" class="btn btn-primary">Submit</button>
<a href="{{ route('categories.index') }}" class="btn btn-warning">Back</a>
</form>
答案 0 :(得分:1)
您可以使用重定向助手或后退助手。
https://laravel.com/docs/5.7/helpers#available-methods
在您的CategoriesController中:
public function handleFormSubmit (Request $req) {
// form validations...
// DB operations...
return redirect()->route('name.of.route.with.form');
}
OR
public function handleFormSubmit (Request $req) {
// form validations...
// DB operations...
return back();
}
OR
public function handleFormSubmit (Request $req) {
// form validations...
// DB operations...
return redirect()->back();
}