F
Filament2w ago
Xavi

Set Column with header action

How can i set a text column value by header action button? I try with $set, but it throws this error
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
Thanks
Solution:
maybe ```php ->action(function () { SendPostToCustomerAction::run($this->record); $this->refreshFormData(['status']);...
Jump to solution
5 Replies
LeandroFerreira
could you explain what are you trying to do?
Xavi
XaviOP2w ago
I have a form, with Header Action buttons.
Actions\Action::make('send_to_customer')
->label(__('Enviar al cliente'))
->visible(fn(Post $post) => $post->isSendableToCustomer())
->requiresConfirmation()
->action(function () {
SendPostToCustomerAction::run($this->record);

//$set('status', Post::CUSTOMER_CHECK);
}),
Actions\Action::make('send_to_customer')
->label(__('Enviar al cliente'))
->visible(fn(Post $post) => $post->isSendableToCustomer())
->requiresConfirmation()
->action(function () {
SendPostToCustomerAction::run($this->record);

//$set('status', Post::CUSTOMER_CHECK);
}),
This run an action (change Post status and send email). In this form i have a select that shows current status, and i want to change it after action its executed. I try to use $set but it throws this error
LeandroFerreira
on EditPage, right?
Solution
LeandroFerreira
maybe
->action(function () {
SendPostToCustomerAction::run($this->record);
$this->refreshFormData(['status']);
})
->action(function () {
SendPostToCustomerAction::run($this->record);
$this->refreshFormData(['status']);
})
?
Xavi
XaviOP2w ago
It works perfect, thanks @Leandro Ferreira !
Want results from more Discord servers?
Add your server