Setting a field value from an action
This is my action:
Actions\Action::make('gespreksverslag_herschrijven')
->label('Gespreksverslag herschrijven')
->icon('heroicon-o-pencil')
->action(function(){
$originalText = $this->data['conversation_report_original']; $service = new RewriteTextWithGPTService(); $rewrittenText = $service->handle(static::$prompt, $originalText); $this->form->fill([ 'conversation_report_gpt' => $rewrittenText, ], true);
}),
Im trying to fill the field 'conversation_report_gpt' but it's not filling anything. I also tried other things such as $this->data['conversation_report_gpt'] = $something and $set() but none of them works for me. This action resides in a Create page of resource
$originalText = $this->data['conversation_report_original']; $service = new RewriteTextWithGPTService(); $rewrittenText = $service->handle(static::$prompt, $originalText); $this->form->fill([ 'conversation_report_gpt' => $rewrittenText, ], true);
}),
Im trying to fill the field 'conversation_report_gpt' but it's not filling anything. I also tried other things such as $this->data['conversation_report_gpt'] = $something and $set() but none of them works for me. This action resides in a Create page of resource
1 Reply
Got it working. No idea if it's the right way to do it, but here is a solution: