F
Filament7mo ago
Mike

Viewfield not updating state

I'm using tiptap editor as it fits my needs. I created a hintAction in order to display a content preview modal. The issue is that the viewfileld data does not update the state when 'content' data is changed. Code as per below: TiptapEditor::make('content') ->required() ->disk('s3') ->live() ->afterStateUpdated(function (Forms\Get $get, Set $set) { $set('post_content', $get('content')); }) ->hintAction( Forms\Components\Actions\Action::make('preview') ->label('Preview Post') ->icon('heroicon-s-eye') ->form([ PreviewPost::make('post_content') ->label('') ->live() ->viewData([ 'post_content' => $form->model->content ]), ]) ->modalSubmitAction(false) ->modalCancelActionLabel('Close') ) There might be a better solution to mine but this is what i could come up with
Solution:
Resolved it using $get thank you
Jump to solution
3 Replies
Andrew Wallo
Andrew Wallo7mo ago
You probably need to somehow pass the view data through a closure.. Or why is there even a need to pass view data if you can use the $state of the form field for post_content in the view?
Mike
MikeOP7mo ago
I cannot use closures, as it exprects mixed @Andrew Wallo how do i do that
Solution
Mike
Mike7mo ago
Resolved it using $get thank you
Want results from more Discord servers?
Add your server