© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
20 replies
Andrew Wallo

Is it possible to use Filament fields inside custom "Livewire" Action classes?

So, if you are aware of the Action classes that are implemented in a plugin similar to Jetstream, you might understand what I am speaking about. If not, I will explain.

In the hierarchy of a Custom Action class, first there is a registered class/callback such as an Interface using the
singleton()
singleton()
design pattern. This Interface contains methods needed to implement the Action class. First, there is a Livewire Component that contains a method using Interface Injection variant of the Dependency Injection design pattern like this.

The Livewire Component:
namespace Wallo\FilamentCompanies\Http\Livewire;

use Livewire\Component;
use Wallo\FilamentCompanies\Contracts\UpdatesCompanyNames;

class UpdateCompanyNameForm extends Component
{
    /**
     * Update the company's name.
     */
    public function updateCompanyName(UpdatesCompanyNames $updater): void
    {
        $updater->update($this->user, $this->company, $this->state);
    }
}
namespace Wallo\FilamentCompanies\Http\Livewire;

use Livewire\Component;
use Wallo\FilamentCompanies\Contracts\UpdatesCompanyNames;

class UpdateCompanyNameForm extends Component
{
    /**
     * Update the company's name.
     */
    public function updateCompanyName(UpdatesCompanyNames $updater): void
    {
        $updater->update($this->user, $this->company, $this->state);
    }
}


This is then extended by the Action class like this:
namespace App\Actions\FilamentCompanies;

use App\Models\Company;
use App\Models\User;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Validator;
use Wallo\FilamentCompanies\Contracts\UpdatesCompanyNames;

class UpdateCompanyName implements UpdatesCompanyNames
{
    public function update(User $user, Company $company, array $input): void
    {
        Gate::forUser($user)->authorize('update', $company);

        Validator::make($input, [
            'name' => ['required', 'string', 'max:255'],
        ])->validateWithBag('updateCompanyName');

        $company->forceFill([
            'name' => $input['name'],
        ])->save();
    }
}
namespace App\Actions\FilamentCompanies;

use App\Models\Company;
use App\Models\User;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Validator;
use Wallo\FilamentCompanies\Contracts\UpdatesCompanyNames;

class UpdateCompanyName implements UpdatesCompanyNames
{
    public function update(User $user, Company $company, array $input): void
    {
        Gate::forUser($user)->authorize('update', $company);

        Validator::make($input, [
            'name' => ['required', 'string', 'max:255'],
        ])->validateWithBag('updateCompanyName');

        $company->forceFill([
            'name' => $input['name'],
        ])->save();
    }
}

My question:
Is it possible to use Filament fields in the Action class instead of what is used here so that Users of my package can change the fields without touching the blade view? If so, how could this be done?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Filament Action inside a custom Livewire component
FilamentFFilament / ❓┊help
2y ago
FIlament Bulk Action inside Livewire Component
FilamentFFilament / ❓┊help
2y ago
Is it possible to implement use vue component inside filament?
FilamentFFilament / ❓┊help
17mo ago