I have created a textarea with a wysywig text editor on it. The user would click into the textarea and start typing like any text editor. They would then save the form with that text and the data would then be saved into the database with $data['description'] = json_encode($description_data);
this would save encoded string into the database.
The following is what I would get in the db column:
""<h1>test<\/h1>
<p>paragraph<\/p>
<p><u><em><strong>some text<\/strong><\/em><\/u><\/p>
""
The reason this is in this format is because it is part of some json output as part of an api and the app needs the text to be converted in this format.
My main issue is this, when the admin goes to edit that data in the textarea the text is added back in as the data above which is expected as you can see below:
This text needs to have none of this wrapping the content and be plain normal html in the textarea. Is this possible?
Here is the controller function below:
public function store(Offer $offer)
{
$offerId = $offer['id'];
$data = Input::except('image','featured');
//$featured_data = array( 'offer_date' => $data['offer_date'], 'starttime' => $data['offer_start_time'], 'endtime' => $data['offer_end_time'] );
$description_data = $data['description'];
$validation = Validator::make($data, Offer::$rules);
if ($validation->fails()) {
return redirect('offers')->with('message', $validation->errors());
} else {
$file = Input::file('image');
$filename = date('Y-m-d-H')."-".$file->getClientOriginalName();
$path = storage_path('app/uploads/' . $filename);
Image::make($file->getRealPath())
->resize(600, 600)
->save($path);
$data['image'] = 'storage/app/uploads/'.$filename;
$data['description'] = json_encode($description_data);
Offer::create( $data );
return redirect('offers')->with('message', 'Offer added!');
}
}
And in the form I have got this:
<div style="clear: both;" class="form-group">
{!! Form::label('description', 'Offer Description:') !!}
{!! Form::textarea('description', null, array('id'=>'editor1','class' => 'ckeditor form-control')) !!}
</div>
Hopefully this can be achieved.