Being new to Laravel, I do not quite understand how to add my input parameter in the form action controller as parameter. I have a page which has an input field (id = mapsearch).
When I put some value in mapsearch and hit enter my url should change from /reviews to /reviews/{mapsearch}
I have the controller in place, however when I add the variable in form controller it does not work.
Route::get('/reviews/{mapsearch}','SearchController@resendReviews');
And the code for opening the form.
{!! Form::open(array('action' => array('SearchController@postReviews', [$mapsearch]))) !!}
Please let me know what should be the value of parameter when the id of my input field is $mapsearch.
You can use whatever name you want in the parameter. In the resendReviews method of the SearchController use the parameter as:-
function resendReviews($id)
{
//The value of mapsearch will pass here.
//U can name id whatever u want.
echo $id;
}
Also if you are posting a form to a controller then you can access the posted data using..
function resendReviews($id)
{
$input = Input::all();
print_r($input);
}
But remember to use the following line when using Input.In the beginning a of Controller file add...
use Input;