The problem is, it's not just one variable, but statements with @if
, @isset
and @foreach
directives. I can't remove whitespaces without syntax error. And all these whitespaces are displaying in input fields.
In description field I did this:
Check, if
old('description')
exists.If yes, display it.
If not, then check, if variable
$post
exists (I use this form for store and update methods both).If yes, display it.
If not, the field remains empty.
<div class="form-group"> <label for="description">Description</label> <textarea id="description" name="description" rows="3">@if(old('description')){{ old('description') }}@else @isset ($post){{$post->description}}@endisset @endif</textarea>
<div class="form-group"> <label for="tags">Tags</label> <input type="text" name="tags" id="tags" value="@isset ($post, $tags)@foreach($post->tagged as $tagged){{$tagged->tag_name}},@endforeach @endisset">
I tried package hedronium/spaceless-blade, but it doesn't work with input values.