首页 > 解决方案 > PHP Laravel Trix 所见即所得如何显示数据库中的内容

问题描述

我使用 laravel 6.0 并且对 Trix 所见即所得有问题。如何获得 trix 编辑器的价值。问题不在于如何将它传递给我使用 trix 的视图,问题在于如何显示它 - 例如这里我通过“值”获取内容(标题):

Title: </br><input type="text" id='title' name='title' value="{{$article->title}}"></br>

但是如何在 Trix 中使用 $article->title 来编辑它呢?:)

 @trix(\App\Article::class, 'title')

标签: phplaravelwysiwygtrix

解决方案


只需为 trix 的隐藏输入赋值


 <input id="short_desc" type="hidden" name="product_short_description" value="{{ $product->product_short_description ?? "" }}" >
 <trix-editor input="short_desc" placeholder="Product short description"></trix-editor

推荐阅读