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 with3 Replies
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?
I cannot use closures, as it exprects mixed
@Andrew Wallo how do i do that
Solution
Resolved it using $get thank you