【问题标题】:How to use variable in value attribute of textarea in Laravel - Blade?如何在 Laravel - Blade 的 textarea 值属性中使用变量?
【发布时间】:2019-06-15 18:41:46
【问题描述】:

我有以下刀片文件。我正在传入一个带有标题和描述的项目对象,并且我想填充值属性。 description 变量在 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

【问题讨论】:

    标签: php laravel variables textarea laravel-blade


    【解决方案1】:

    textarea 标签中没有value 属性。相反,将值放在打开和关闭标记之间:

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

    更多信息请参见this link

    【讨论】:

      【解决方案2】:

      应该是这样的

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-10-21
        • 2018-04-03
        • 2017-04-29
        • 2018-05-27
        • 2021-11-29
        • 2012-10-11
        相关资源
        最近更新 更多