murdercode / Nova4-TinymceEditor

A TinyMCE Field for Laravel Nova 4
MIT License
15 stars 12 forks source link

Don't work with json fields :( #26

Open dprhmk opened 5 months ago

dprhmk commented 5 months ago

My code is :

  TinymceEditor::make('Content', 'data->main->text->en')
        ->fullWidth()

  or

  TinymceEditor::make('Text', 'data->text')
         ->fullWidth(),

Знімок екрана 2024-05-23 о 10 48 05

davidelvir commented 5 months ago

You can work around it by using resolveUsing and fillUsing.

TinymceEditor::make('Text', 'text')
                ->resolveUsing(function ($value, $model) {
                    return $model->data['text'] ?? '';
                })->fillUsing(function ($request, $model, $attribute, $requestAttribute) {
                    $data = $model->data;
                    $content[$attribute] = $request->input($attribute);
                    $model->data = $data;
                })