© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
69 replies
Saade

Bind $record in a custom action

Giving the following component:

// Component
class MyPage extends Component implements HasForms, HasActions
{
    use InteractsWithForms;
    use InteractsWithActions;

    public function editAction(): Action
    {
        return Action::make('edit')
            ->mountUsing(function (Action $action, array $arguments): void {
                // Resolve 
                $record = Author::find($arguments['id']);

                // I'm guessing this, this will not work.
                $action->record($record);
            })
            ->form([
                TextInput::make('title'),
                Repeater::make('books')->relationship('books') // Repeater must know $record in order to work
            ])
            ->action(function (array $data, Model $record) {
                $record->update($data);
            })
    }
}
// Component
class MyPage extends Component implements HasForms, HasActions
{
    use InteractsWithForms;
    use InteractsWithActions;

    public function editAction(): Action
    {
        return Action::make('edit')
            ->mountUsing(function (Action $action, array $arguments): void {
                // Resolve 
                $record = Author::find($arguments['id']);

                // I'm guessing this, this will not work.
                $action->record($record);
            })
            ->form([
                TextInput::make('title'),
                Repeater::make('books')->relationship('books') // Repeater must know $record in order to work
            ])
            ->action(function (array $data, Model $record) {
                $record->update($data);
            })
    }
}


<div>

    Authors:

    <span>Guilherme Saade {{ ($this->editAction)(['id' => 1]) }}</span>
    <span>Dan Harrin {{ ($this->editAction)(['id' => 2]) }}</span>

    <x-filament-actions:modals/>
</div>
<div>

    Authors:

    <span>Guilherme Saade {{ ($this->editAction)(['id' => 1]) }}</span>
    <span>Dan Harrin {{ ($this->editAction)(['id' => 2]) }}</span>

    <x-filament-actions:modals/>
</div>


How can i make the repeater know that the record is the $record resolved on mount?

Made a little repro repo with everything set up, no need for migrations and seeders
https://github.com/saade/filament-lab/tree/action-record
Solution
Hey @Dan Harrin, is this something you could still work on? Or perhaps point me in the right direction. Thanks!

I think Bind $record in a custom action got implemented since when i've created this thread, the issue seems to be solved, thank you!
Jump to solution
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
Next page

Similar Threads

Getting owner record in custom association action
FilamentFFilament / ❓┊help
2y ago
Get current row record in custom action
FilamentFFilament / ❓┊help
2y ago
Updating record with custom action
FilamentFFilament / ❓┊help
2y ago
Custom Action in RelationManager with current record injection
FilamentFFilament / ❓┊help
3y ago