Markdown Editor: Array to string conversion error

I have a relation manager with a form which contains a markdown editor. 1. The problem is every time I´m trying to create a record with CreateAction I get this error: Illuminate\Database\QueryException: Array to string conversion. 2. When editing a record with EditAction my text of the markdown editor will be saved like this in the database: input text: "TEST", in database:
{"type":"doc","content":[{"type":"paragraph","content":[]}]}
{"type":"doc","content":[{"type":"paragraph","content":[]}]}
3. When doing dd($data) I get this for the markdown editor field:
"body" => array:2 [
"type" => "doc"
"content" => array:1 [
0 => array:3 [
"type" => "paragraph"
"attrs" => array:1 [
"textAlign" => "start"
]
"content" => array:1 [
0 => array:2 [
"type" => "text"
"text" => "TEST"
]
]
]
]
]
"body" => array:2 [
"type" => "doc"
"content" => array:1 [
0 => array:3 [
"type" => "paragraph"
"attrs" => array:1 [
"textAlign" => "start"
]
"content" => array:1 [
0 => array:2 [
"type" => "text"
"text" => "TEST"
]
]
]
]
]
4. When using ViewAction it does not open up the modal, I instantly get the error: ErrorException: Array to string conversion Code:
public function form(Schema $schema): Schema
{
return $schema
->components([
MarkdownEditor::make('body')
->columnSpanFull()
->required()
->maxLength('4000')
->toolbarButtons(['bold', 'italic', 'orderedList', 'redo', 'strike', 'undo'])
]);
}

public function table(Table $table): Table
{
return $table
->headerActions([
CreateAction::make('newMessage')
->using(fn (array $data) => dd($data))
])
}
public function form(Schema $schema): Schema
{
return $schema
->components([
MarkdownEditor::make('body')
->columnSpanFull()
->required()
->maxLength('4000')
->toolbarButtons(['bold', 'italic', 'orderedList', 'redo', 'strike', 'undo'])
]);
}

public function table(Table $table): Table
{
return $table
->headerActions([
CreateAction::make('newMessage')
->using(fn (array $data) => dd($data))
])
}
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?