filament-editorjs
filament-editorjs copied to clipboard
Field empty after reload edit page
- Open edit form with EditorJs field
- Edit something in this field
- Data saved into database -> ok
- Re-open edit form. EditorJs field is empty =(
What am i doing wrong?
You have to decode it first. add it inside json_decode() method
public $body;
public function mount($id): void
{
$this->post = Post::find($id);
$this->form->fill([
'body' => json_decode($this->post->body, true),
]);
}
thank u very much! It would be cool if you add it to the readme)
@TempleOfTemplar you can cast body field to array in model. So you don't need to modify mount method
@TempleOfTemplar you can cast body field to array in model. So you don't need to modify mount method
The issue with that, when you try to render the data again with the editor js in read only mode. it's giving error.
<div
wire:ignore
class="editorjs-wrapper"
x-data="editorjsreadonly({
data: {{ $post->body }}
})"
>
when body is cast, you receive that message:
htmlspecialchars(): Argument #1 ($string) must be of type string, array given
<div wire:ignore class="editorjs-wrapper" x-data="editorjsreadonly({ data: {{ $post->body }} })" >
Where's this code come from??
@rahmanramsi I made a read only editor.js for my websites front end it's not from your package, I'm using your package with Filament form, to save the data. then I have a separate editor.js read only to read the data. but I'm using the same approach you used to implement it in Laravel with a different id "editorjsreadonly" https://editorjs.io/configuration#read-only-mode