Form submit going to the wrong route

html form
laravel html form
laravel collective form example
form method=post'' action
how to pass parameters in form action in html
where does html form data go
html form method=put
laravel 6 forms

I am saving data from a simple form in my Laravel project.

While submitting, it should go to the route that is predefined for store() method. I use such code:

{!! Form::open(['action' => 'PostsController@store', 'method' => 'POST', 'enctype' => 'multipart/form-data']) !!}

It goes to the route that is for index() method. Any help?

In store() method, I have such code:

$posts = new Post;

$posts->title = $request->input('title');
$posts->body = $request->input('body');
$posts->save();

return redirect('/');

My web.php contains:

Route::resource('/','PostsController');

Your code is correct bro.. The only reason you're going to index is because of the return redirect('/'); in the store function... Check whether youdata is saved in the database or not...

form submition to the wrong route, when i try to submit the login form it goes to the wrong route to the logout route with MethodNotAllowedHttpException error with no message. I setting a up a select_tag called 'dir_list' to use form submit on change to call a method. This method 'file_dir', will generate a list of files based on the selection from dir_list and the rende

Have you tested to see if this actually saves the data still? With Route resources, the route will be the same for both store and index methods, just a different HTTP method.

Why is my form posting to wrong route?, My form appears to be posting the wrong route and I have not idea why. The world is not going to explode if he doesn't use it, but it looks like  I am not sure what is going wrong as I am asking for the PUT action and the pair object is trying to do a post. Thanks ruby-on-rails-3 routing put form-for controllers

Maybe your code is working well & data saved in the database. You return redirect('/') it to your index() method, so you don't understand the difference. Check your database.

Sending form data, First we'll discuss what happens to the data when a form is submitted. more than a convenient user-friendly way to configure an HTTP request to send data to a server. a set of global metadata about the browser's capabilities, and a body that can A first splash into JavaScript · What went wrong? Make sure that you do not have the form tags nested. When you drop the treeview on the form it no doubt puts form tags at the beginning and end of your master page. Edit the source so that the form tag with the runat="server" only surrounds the TreeView. Then have another form tag with your mvc form action. I've tested this and it does work.

Sending forms through JavaScript, HTML forms can send an HTTP request declaratively. Let's first talk about why this requires a different approach. Something went wrong. provides a simpler way to handle form data requests with the FormData object. Edit(int) displays a form to edit a product. Edit(int, Product) processes the posted form. To resolve the correct route: Edit(int, Product) is selected when the request is an HTTP POST. Edit(int) is selected when the HTTP verb is anything else. Edit(int) is generally called via GET.

Forms & HTML - Laravel, You may also open forms that point to named routes or controller actions: If your form is going to accept file uploads, add a files option to your array: If you have contacted the financial institution and two weeks have passed with no results, you will need to file Form 3911, Taxpayer Statement Regarding Refund (PDF) to initiate a trace. This allows the IRS to contact the bank on your behalf to attempt recovery of your refund.

Veterinary Pharmacovigilance: Adverse Reactions to Veterinary , Adverse events for this marketed product are submitted to the CVM Office of the wrong dosage, wrong species and wrong route of administration, or used for an with prompt written follow up using FDA Form 1932: Veterinary Adverse Drug  This may be represented in the same way as values passed to url_for or link_to. So for example you may use a named route directly. When the model is represented by a string or symbol, as in the example above, if the :url option is not specified, by default the form will be sent back to the current URL

Comments
  • Please post your routes file.
  • I will add it to my post
  • Can you also show us the rest of the form please.
  • First of all, don't use laravelcollective's form. This is an old style. You can do everything without it.
  • @SandOfVega I do not know that much in Laravel. I am watching the videos where he uses this form. Thanks
  • It is not saved. Even if I don't write any redirect statement it goes to my index.
  • If I rename this post-method route, for example, Route::post('/store'), it works. The problem seems to be in my form.
  • More of a comment than an answer but the 2nd sentence is correct.