如何在 Laravel - Blade 的 textarea 的值属性中使用变量?

How to use variable in value attribute of textarea in Laravel - Blade?

我有以下 blade 文件。我正在传递一个带有标题和描述的项目 object,我想填充值属性。描述变量在 p-tag 中有效,但在 textarea-tag 中无效。 $title 变量也可以正常工作。为什么它在文本区域中不起作用?

@extends('layout')

@section('content')

    <h1 class="display-4">Edit Project</h1>


    <p>{{ $project->description }}</p>


    <form>

      <div class="form-group">
        <label for="title">Title</label>
        <input type="text" class="form-control" name="title" placeholder="Title" value="{{ $project->title }}">
      </div>

      <div class="form-group">
        <label for="description">Description</label>
        <textarea type="text" class="form-control" name="description" value="{{ $project->description }}"></textarea>
      </div>


      <button type="submit" class="btn btn-primary">Update Project</button>
    </form>
@endsection

textarea 标签中没有 value 属性。相反,将值放在开始和结束标记之间:

<textarea type="text" class="form-control" name="description">{{ $project->description }}</textarea>

有关详细信息,请参阅 this link

应该是

<textarea type="text" class="form-control" name="description" >{{ $project->description }}</textarea>