I want to pass data through route then assign to the text box for edit in modal
popup.
My controller code is:
public function edit($id) {
$abc = property_type::find($id);
return redirect('/admin/property-type')->with('popup','open');
}
Popup is to open modal popup. $abc
has three values: ID, name and description. I want to assign description and name with two different text box:
<input type="text" class="form-control" value="{{Session::get('abc')}}" name="update_prop_name" >
<input type="text" class="form-control" value="{{Session::get('abc')}}" name="update_prop_desc" >
I don't see anywhere where you're setting abc
into session, so value="{{ Session::get("abc") }}
will be null
.
Add this to your edit
function:
public function edit($id){
$abc = property_type::find($id);
session()->put("abc", $abc);
return redirect("/admin/property-type")->with(["popup" => "popup"]);
}
Also, using session()->get("abc")
will return the whole object, and not a specific property. Might want to adjust to:
<input type="text" class="form-control" value="{{ session::get("abc") ? session()->get("abc")->name : "" }}" name="update_prop_name" />
<input type="text" class="form-control" value="{{ session::get("abc") ? session()->get("abc")->description : "" }}" name="update_prop_desc" />
Note: the ternary ?
operator will also handle session()->get("abc")
returning null