Just using the HTML form, how can I submit a form to a store function in the resource controller, if the route is /register. Please help, I've tried inserting 'post' method in the form tag,it's not working. Meanwhile the name of the store route is customer.store. I just don't know how to go about it.
Asked
Active
Viewed 867 times
0
-
Set up a route to handle the `POST` request that you are sending via `/register` to the appropriate controller and function... What have you tried so far? Do you have any code that we can help you debug? – James Jul 11 '16 at 01:37
-
The it's a resource route pointing to a resource controller. I just wanna be able to submit my form to the store function in the controller – Hammed Dapo Ajibade Jul 11 '16 at 02:36
1 Answers
1
Like James said, simply create a post-route, to which your form-submit points. Then set this route to your store-function in your controller. If you have the route::auth()
in your routes, put this to the end. This one catches normally catches your /register
route.
Your form:
<form method="post" action="{{ url('/register') }}">
<!-- Don't forget your csrf -->
{!! csrf_field() !!}
<!-- Rest of your form -->
<button type="submit">Register</button>
</form>
Your routes.php
// GET
Route::get('/register', function(){
return view('register-form');
});
//or
Route::get('/show-form', 'FormController@showForm');
//POST
Route::post('/submitted-form', 'FormController@register');
//GET and POST combined
Route::match(['get', 'post'], '/form-handler', 'FormController@formHandler');
//And finally
route::auth();
But maybe you could hook in the AuthController
. This controller normally handles the registrations (take a look at the register
method in combination with the create
method).

Brotzka
- 2,959
- 4
- 35
- 56