Laravel multiple submit button with different actions

On the form or view

<button type="submit" class="btn btn-primary" name="submit" value="submit">Save & Go BACK</button>
<button type="submit" class="btn btn-primary" name="save" value ="save">Save Note</button>

On the controller

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Note;
use App\Card;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Input;
use App\Http\Requests;

class NotesController extends Controller
public function store(Request $request, Card $card){
$card->addNote(new Note($request->all()));
return back();

public function edit(Note $note){
return view('note.edit', ['note' => $note]);

public function update(Note $note, Request $request){
if(Input::get('submit')) {
return redirect('/card/'.$note->card_id); //save and go back to card

}else if(Input::get('save')){
         $note->update($request->all()); //save and stay on the page
         return back();

3 thoughts on “Laravel multiple submit button with different actions”

Leave a Comment

Your email address will not be published. Required fields are marked *