dimanche 12 avril 2015

How to send and access a parameter/value upon Form Submission to next controller

I am new to Laravel. I have a controller method which retrieves data from request, creates a model instance and saves it to database.


It then redirects to controller with a value (user name)



return redirect()->action('SignupController@confirm' , $username);


Route for confirm is :



Route::get('confirm/{user}' , 'SignupController@confirm');


In 'confirm' method i retrieved value from variable and passed it to view



public function confirm($username)
{
return view('auth.confirm')->with('username' , $username);
}


Confirm view present a form to confirm account and upon succesful submission post to route :



Route::post('confirm' , 'SignupController@confirmCode');


In 'confirmCode' i want to access that value which i actully fetched from user input and passed down the line. But i am unable to do it , i even tried post route with a wild card



Route::post('confirm/{user}' , 'SignupController@confirmCode');


and tried to access it similarly as before , but it is not passed along when form submits as i get nothing when i tried to look for it using var_dump($username).


Error is :



Missing argument 1 for App\Http\Controllers\SignupController::confirmCode()


By the way, temporarily i am using hidden field to do the job which is not a good idea obviously. I know i am missing something. Looking forward for some advice. Thanks in advance.


Aucun commentaire:

Enregistrer un commentaire