© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
12 replies
Patrick Boivin

Using protected properties on form actions

Is it safe to store a protected property on a form action?
class MyFormAction extends Action
{
    protected bool $myOption = false;

    protected function setUp(): void
    {
        parent::setUp();

        $this->label('My Action')
            ->action(function () {
                if ($this->myOption) {
                    // ...
                } else {
                    // ...
                }
            });
    }

    public function myOption(bool $myOption = true): static
    {
        $this->myOption = $myOption;

        return $this;
    }
}
class MyFormAction extends Action
{
    protected bool $myOption = false;

    protected function setUp(): void
    {
        parent::setUp();

        $this->label('My Action')
            ->action(function () {
                if ($this->myOption) {
                    // ...
                } else {
                    // ...
                }
            });
    }

    public function myOption(bool $myOption = true): static
    {
        $this->myOption = $myOption;

        return $this;
    }
}
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Using panel form actions in custom form
FilamentFFilament / ❓┊help
2y ago
Using json properties for form schema
FilamentFFilament / ❓┊help
12mo ago
Form Components only for on form actions
FilamentFFilament / ❓┊help
2y ago
How to place form actions on header actions
FilamentFFilament / ❓┊help
3y ago