Trix editor with laravel livewire not displaying database data

223 Views Asked by At

im trying to display data from the database from the trix editor using laravel livewire. The content gets saved in the database but after i reload content disappears from the page even though the content is saved in the database. This is my livewire component

public WhyMe $whyMe;
protected function rules(): array
    {
        return [
            "whyMe.description" => ["required","min:50","max:1000", "string"],
        ];
    }

    public function mount(): void
    {
        $this->whyMe = $this->makeBlankWhyMe();
    }

    public function makeBlankWhyMe(): WhyMe
    {
        return WhyMe::make([]);
    } 

this is my rich-text component

@props(['initialValue' => ''])

<div
    class="rounded-md shadow-sm col-span-6"
    wire:ignore
    {{ $attributes }}
    x-data
    @trix-blur="$dispatch('change', $event.target.value)"
>
    <input id="x" value="{{ $initialValue }}" type="hidden">
    <trix-editor input="x" class="form-textarea block w-full transition duration-150 ease-in-out sm:text-sm sm:leading-5"></trix-editor>
</div>

and here is the view where the component is being called from

 <x-rich-text wire:model.lozy="whyMe.description" id="description" :initial-value="$whyMe->description" />
                <x-input-error for="whyMe.description" class="mt-2"/>

What am i doing wrong?

I've tried countless things and at this point my brain is checked out. Any help is appriciated.

1

There are 1 best solutions below

0
kristi tanellari On

Changed :initial-value="$whyMe->description" to :initialValue="$whyMe->description" and everything worked.