lundi 11 juin 2018

laravel blade form not routing to a named route

I am new to named routing in Laravel 5.5 and I am facing a strange thing while trying to perform an action of a form;

Setups and Explanations:

I set up my routes in web.php

Route::post('questions/save_bulk', 'QuestionsController@save_bulk')->name('save_bulk');
Route::post('questions/store_bulk', 'QuestionsController@store_bulk')->name('store_bulk');

Then I set up store_bulk and save_bulk in QuestionsController:

public function store_bulk(Request $request)
{
    //$x = some DB::selects statements;
    return view('questions.store_bulk', ['x'=> $x]);
}

public function save_bulk(Request $request){
    dd($request);
}

And finally this is my blade form in questions.store_bulk which should lead to QuestionsController.save_bulk:

<form method="post" action="">
        

        /* some codes and input fields */

        <div class="form-group">
            <input type="submit" class="btn btn-primary" value="Submit"/>
        </div>

</form>

Problem

The problem is that when I submit this form, instead of taking me to the desired route and perform dd($request), it is just refreshing the page without the inputs I had as if Laravel took the last post form which returned the view questions.store_bulk. Though this is the exact same way I used to get into the view questions.store_bulk in the first place, a strange thing occurs: when I try to inspect elements in the blade page I get the following:

<form method="post" action="http://127.0.0.1:8000/questions/store_bulk">

/* some codes and inputs */

</form>

in the codes the route should go to QuestionsController.save_bulk but when inspecting the HTML it says it goes to http://127.0.0.1:8000/questions/store_bulk

Question

Why is this happening? am I missing something?

Note

I am using Laravel 5.5 locally on my PC preparing a website.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2l0hmOd
via IFTTT

Aucun commentaire:

Enregistrer un commentaire