Search code examples
phplaraveleloquentmodeltrix

Laravel - How do i insert text into trix editor


I was wondering how could I introduce text from my database trix field back into the editor for further editing. Thank you in advanced !


Solution

  • let's say you have a model $trixText and there is a field text. So you can populate with this. You can set the content by putting in the value attribute.

    <form …>
      <input id="x" value="{{ $trix->text }}" type="hidden" name="text">
      <trix-editor input="x"></trix-editor>
    </form>