DEV Community

Süleyman Özgür Özarpacı
Süleyman Özgür Özarpacı

Posted on Edited on

How to Refresh Form Data in FilamentPHP Action

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']);
  })
Enter fullscreen mode Exit fullscreen mode

The action button updates the is_active column, then refreshes the is_active column.

Top comments (0)