I insert some code into my database. When I open the database and copy the field which holds the code, it paste like the fllowing
<div class="form-group-handle">
<label for="text_input" class="control-label col-sm-4">Text Input</label>
<div class="controls col-sm-7">
<input id="text_input" class="form-control" name="text_input" type="text">
</div>
</div> <div class="form-group-handle">
<label for="textareaInput" class="col-sm-4 control-label">Text Area:</label>
<div class="controls col-sm-7">
<textarea rows="5" class="form-control" id="textareaInput" name="textareaInput" cols="50"></textarea>
</div>
</div>
So everything appears fine, just what I expect. Now in Laravel I need to get this code. So I do the following
$documentData = DocumentTemplate::where('name', $documentLink)->first(['form_data', 'form_data']);
And I pass this to my view. Within my view, I do the following
{!!
Form::model(new App\Document, [
'class'=>'form-horizontal',
'route' => ['projects.documents.store', $project->id],
'files' => true
])
!!}
{!! $documentData !!}
<div class="form-group">
{!! Form::label('filePath', 'Document:', array('class' => 'col-md-5 control-label green')) !!}
<div class="col-md-7">
{!! Form::file('filePath[]', array('multiple'=>true)) !!}
</div>
</div>
{!! Form::close() !!}
When I check the output, it is a mess. If I view source, the HTML looks something like the following
<form method="POST" action="http://localhost:8000/documents" accept-charset="UTF-8" class="form-horizontal" enctype="multipart/form-data"><input name="_token" type="hidden" value="uyg">
{"form_data":"<div class=\"form-group-handle\">\n <label for=\"text_input\" class=\"control-label col-sm-4\">Text Input<\/label>\n <div class=\"controls col-sm-7\">\n <input id=\"text_input\" class=\"form-control\" name=\"text_input\" type=\"text\">\n <\/div>\n <\/div> <div class=\"form-group-handle\">\n <label for=\"textareaInput\" class=\"col-sm-4 control-label\">Text Area:<\/label>\n <div class=\"controls col-sm-7\">\n <textarea rows=\"5\" class=\"form-control\" id=\"textareaInput\" name=\"textareaInput\" cols=\"50\"><\/textarea>\n <\/div>\n <\/div>"}
<div class="form-group">
<label for="filePath" class="col-md-5 control-label green">Documents:</label>
<div class="col-md-7">
<input multiple="1" name="filePath[]" type="file">
</div>
</div>
</form>
So it appears to add backslashes all over the place, and things like \n.
Why would this be happening?
Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire