How to Refresh Form Data in FilamentPHP Action
Süleyman Özgür Özarpacı
Posted on May 19, 2023
If you have to refresh form data after an action, you can use refreshFormData
method. Method gets array as a first parameter. The array must contain columns that need to be updated.
For example, you can create a Toggle Active action button like this:
use Filament\Pages\Actions;
Actions\Action::make('Toggle Active')
->icon('heroicon-o-lock-open')
->action(function() {
$this->record->update(['is_active' => !$this->record->is_active]);
$this->refreshFormData(['is_active']);
})
The action button updates the is_active
column, then refreshes the is_active
column.
💖 💪 🙅 🚩
Süleyman Özgür Özarpacı
Posted on May 19, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.