MaximeBTD MaximeBTD - 4 months ago 33
PHP Question

Laravel value in TextArea

I'm getting a strange issue with Laravel and HTML's Text Areas and I can't figure out how to bypass it. Here is the code of my textarea :

<div class="col-md-3">
<label for="comment">Commentaire:</label>
<textarea class="form-control" id="comment">
@foreach ($comments as $com)

So I'm getting multiples results from my controller, and I would like to add all of them to the text box. The problem I have is indentation.

The tabulations are written in the textarea. So if i delete all indentation, result is correct, but my code isn't (I can't leave a part of code like that).
Any solution to avoid the tabs in the text area ?


I think that's a problem with textarea's because you have tabs in your code it will also add those tabs/spaces into the HTML. So what you need to do is make the entire foreach into one line like this:

    <textarea class="form-control" id="comment">@foreach ($comments as $com){{$com->comment}}@endforeach</textarea>

use HTML or CSS to style it correctly