dimanche 27 mars 2016

Returning View Fails to Update URL in Address Bar - Laravel 5

I am having an issue with Laravel 5 failing to display the correct URL for the view that is currently being displayed in the browser.

My website involves a series of views that each contains a form, and the user is guided through these views in succession and in a particular order to submit all of the information I need from them. There are four such pages, and everything about them is working fine except for the URL display.

What happens is this: We load the first view and the URL displays mypage/1. We submit the form and the second view loads up, but mypage/1 is still in the address bar. When we then submit the form in the second view and load the third view, the URL steps forward once to display mypage/2 in the address bar. In this way, there is a one-page lag between the URL in the address bar and the view actually being displayed.

Example Routes:

Route::get('createproject/start', 'CreateProjectController@start');
Route::post('createproject/start', 'CreateProjectController@sendToCreate');
Route::get('createproject/create', 'CreateProjectController@create');
Route::post('createproject/create', 'CreateProjectController@insertProject');

Example Controller Functions:

public function start()
{
        return view('createproject/start');
}

public function create()
{
    return view('createproject/create');
}

protected function sendToCreate(Request $request)
{
    return view('createproject/create', array('proj_name' => $request->name,
                                       'proj_area_main' => $request->area_main,
                                       'proj_field' => $request->field,
                                       'proj_creator' => $request->creator,
                                       ));
}

Example Form:

// On the start page, the form begins like this...
<form class="form-horizontal" role="form" method="POST" action="{{ url('/createproject/start') }}">
// On the create page, the form begins like this...
<form class="form-horizontal" role="form" method="POST" action="{{ url('/createproject/create') }}">



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire