Reputation: 25
I have 2 submit buttons- 1 for "save", 1 for "show saved list". I want if "subbutton" is clicked, redirect to resource controller public function store(Request $request), if "list" is clicked- redirect to resource controller public function index(). My functions work well. But I dont know how to link them with different buttons.
create.blade.php
<button type="submit" value="subbutton" name="subbutton" class="btn btn-primary">SAVE</button>
<button type="submit" value="list" name="list" class="btn btn-primary">SHOW</button>
Upvotes: 0
Views: 966
Reputation: 7972
A suggestion would be to transform your listing button
to an a
tag
<a href="{{ route('posts.index') }}" class="btn btn-primary">SHOW</a>
thereby, the submit button would carry out the form submission and the anchor tag would list the resources.
Upvotes: 1