简体   繁体   English

Laravel textarea有空白并且没有显示db的值?

[英]Laravel textarea has white space and not showing value from db?

I have a simple textarea tag like this: 我有一个简单的textarea标签,如下所示:

<div class="form-group{{ $errors->has('main') ? ' has-error' : '' }}">
    <label id="main2" for="main" class="col-md-4 control-label">Main</label>
    <div class="col-md-6">
            <textarea id="main" type="text" class="form-control" placeholder="Main Text"
            title="More main text"  name="main" value="{{ $entity->main }}">
            </textarea>
            @if ($errors->has('main'))
            <span class="help-block">
               <strong>{{ $errors->first('main') }}</strong>
            </span>
        @endif
    </div>
</div>

However, instead of actual output from db I get white space so if I click on the field it feels like I have pressed tab 3 times. 但是,不是从db实际输出,而是得到空格,因此如果单击该字段,感觉就像我按了tab 3次。 How can that be solved? 怎么解决呢?

Textarea doesn't support the value attribute. Textarea不支持value属性。 To display the value in textarea you have to place the variable inside the opening and closing <textarea>value</textarea> tags. 要在textarea中显示值,必须将变量放置在开始和结束<textarea>value</textarea>标记内。 So use like this. 所以这样使用。

<textarea id="main" type="text" class="form-control" placeholder="Main Text" title="More main text"  name="main">{{ $entity->main }}</textarea>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM