How to pass dropdown selected value to another page's dropdown in laravel
I want to pass 3 values (2 dropdown's and 1 input field) from one page to another.User will select 2 dependent dropdowns after clicking on the button user will redirect to another page where he will ask to fill-up a form wherein above 3 details will be auto-filled. The input field's data is passing to another page but the 2 dropdown's value are not passing.
Controller
public function getRequestDetails(Request $request){
$reqAOP = $request->get('areas');
$reqType = $request->get('request_type');
$reqTitle = $request->get('title');
Session::put('areas', $request->get('areas'));
return redirect('frontend_template.submitquery')->withInput($request->only('title'));
}
what i understood in your doubt is, you have a form with dropdowns and you will choose the drop down values and those values to be passed to another form when a button is clicked
Am i right?
means you need to do, think that you have form1. you have choosed the dropdowns. think that your dropdown names are dp1 and dp2
then if u click the submit button
it moves to a method in the controller assume that the method is pass_value_to_form2()
so,
public function pass_value_to_form2(Request $request)
{
$dp1=$request->dp1;
$dp2=$request->dp2;
return view('folder_name.form2')->withDp1($dp1)->withDp2(dp2);
}
What dropdowns aren't passing? The 2 select elements you are showing don't have a name attribute, so they aren't sent with the form. Only named form controls are, if they are considered "successful" by the html spec (like a checkbox won't be sent unless it's checked, even if it has a name).
Probably because you are redirecting instead of just returning a view, and passing the variables to the view. Why the need for a redirect? Controller A shows form A. Form A submits to Controller B. Controller B shows Form B using data from Form A that was passed to the view.