Skip to content
Advertisement

Laravel 4 – two submit buttons in one form and have both submits to be handled by different actions

I have a login form which has email and password fields. And I have two submit buttons, one for login ( if user is already registered ) and the other one for registration ( for new users ). As the login action and register action are different so I need some way to redirect the request with all the post data to its respective action. Is there a way to achieve this in Laravel 4 in pure Laravel way?

Advertisement

Answer

The way I would do it

If your form is (2 buttons):

JavaScript

Create a controller ‘TestController’

Add a route

JavaScript

In TestController you’d have one method that checks which submit was clicked on and two other methods for login and register

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement