How to Refresh Form Data in FilamentPHP Action

biostate

Süleyman Özgür Özarpacı

Posted on May 19, 2023

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.

💖 💪 🙅 🚩
biostate
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.

Related