How to set a form value in a resource from a custom action
I have an action that contains a conversation_report_gpt textarea, I would like to update the value of this field after clicking on an action button.
1 Reply
return [
Actions\Action::make('gespreksverslag_herschrijven')
->label('Gespreksverslag herschrijven')
->icon('heroicon-o-pencil')
->fillForm(function($livewire){
$formData = $livewire->form->getRawState();
return [
'conversation_report_original' => $formData['conversation_report_original'],
'prompt' => static::$prompt,
];
})
->form([
Section::make()
->columns(2)
->schema([
TextArea::make('prompt')
->rows(5)
->columnSpanFull(),
Textarea::make('conversation_report_original')
->label('Gespreksverslag origineel')
->rows(10)
->required(),
Textarea::make('conversation_report_gpt')
->reactive()
->label('Gespreksverslag GPT')
->rows(10),
]),
])->action(function(array $data, $arguments, $livewire){
if($arguments['rewrite'] ?? false){
}
})->extraModalFooterActions(function(Action $action): array{
return [
$action->makeModalSubmitAction('Herschrijven', arguments: ['rewrite' => true])
];
}),
...parent::getFormActions(),
];
return [
Actions\Action::make('gespreksverslag_herschrijven')
->label('Gespreksverslag herschrijven')
->icon('heroicon-o-pencil')
->fillForm(function($livewire){
$formData = $livewire->form->getRawState();
return [
'conversation_report_original' => $formData['conversation_report_original'],
'prompt' => static::$prompt,
];
})
->form([
Section::make()
->columns(2)
->schema([
TextArea::make('prompt')
->rows(5)
->columnSpanFull(),
Textarea::make('conversation_report_original')
->label('Gespreksverslag origineel')
->rows(10)
->required(),
Textarea::make('conversation_report_gpt')
->reactive()
->label('Gespreksverslag GPT')
->rows(10),
]),
])->action(function(array $data, $arguments, $livewire){
if($arguments['rewrite'] ?? false){
}
})->extraModalFooterActions(function(Action $action): array{
return [
$action->makeModalSubmitAction('Herschrijven', arguments: ['rewrite' => true])
];
}),
...parent::getFormActions(),
];
)->action(function(Set $set, $arguments){
if($arguments['rewrite'] ?? false){
// i want to update the resource form with the new text here
$set('conversation_report_gpt', 'testing');
$this->halt();
}
})
)->action(function(Set $set, $arguments){
if($arguments['rewrite'] ?? false){
// i want to update the resource form with the new text here
$set('conversation_report_gpt', 'testing');
$this->halt();
}
})
Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization
Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization
TextInput::make('conversation_report_original')
->label('Gespreksverslag origineel')
->required()
->suffixAction(
ActionsAction::make('Herschrijven')
->icon('heroicon-o-pencil')
->action(function(Set $set){
$set('conversation_report_gpt', 'cheese');
$this->halt();
})
)
,
TextInput::make('conversation_report_original')
->label('Gespreksverslag origineel')
->required()
->suffixAction(
ActionsAction::make('Herschrijven')
->icon('heroicon-o-pencil')
->action(function(Set $set){
$set('conversation_report_gpt', 'cheese');
$this->halt();
})
)
,