DEV Community

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

Posted on • Edited on

6 1

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)

Cloudinary image

Zoom pan, gen fill, restore, overlay, upscale, crop, resize...

Chain advanced transformations through a set of image and video APIs while optimizing assets by 90%.

Explore

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay