jeudi 15 novembre 2018

Sending data from MySQL to textarea field

Crated my ReportsController and wrote my CRUD functionality to retrieve data from my MySQL database.

public function edit($id)
{
    $reports = Reports::find($id);
    return view('reports/edit',compact('reports','id'));
}

/**
 * Update the specified resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function update(Request $request, $id)
{
    $report->submitted = true;
    $report->category_id = 10;
    $report->report_title = $request->get('title');
    $report->content = $request->get('content');
    $report->solution = $request->get('solution');
    $report->recommendation = $request->get('recommendation');
    $report->date_submitted = date("d.m.y"); //stores the date format 'd.m.y'
    $report->user_id = 1;
    $report->save();
    return redirect('reports');//->width('success', 'Reports successfully added to database');
}

created an edit.blade.php file which loads up the page templates to show the data when pulled from the database but since I want to push the data from the database into a textarea field. I have one textfield that shows the data being displayed from the database using:

 <input id="title" name="title" placeholder="Enter Title" type="text" class="form-control here" required="required" value="">

After doing some research I found out that textarea uses Input::old('content') instead of values = "content"

<textarea id="message" name = "content" rows="10" cols="50" onKeyPress class="form-control">}

Link to old post question. Tried putting } in the textarea tag but I cannot still get the data in the textarea. Still trying to understand the syxtax so I am unsure whether I am doing something wrong.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire