#Adding a custom action component through a ViewColumn

7 messages · Page 1 of 1 (latest)

supple quarry
#

I've created a action component in which I have included a method :

public function joinAction(): Action
    {
        return Action::make('join')
            ->requiresConfirmation()
            ->action(function () {
                dd('foo');
            });
    }

And on the view (blade) file i'm using {{ $this->joinAction }} like:

<div>
    {{ $this->joinAction }}

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

But i'm still getting an error that Property [$joinAction] not found on component:

What would be the correct setup to achieve this?

deft hollowBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

wintry prawn
#

hi i can help you
DM

minor bobcat
vapid shadow
# supple quarry I've created a action component in which I have included a method : ```php pub...

use action() method in the ViewColumn:

Tables\Columns\ViewColumn::make('view_column')
    ->action(Tables\Actions\Action::make('myAction')
        ->requiresConfirmation()
        ->action(function (YourModel $record) {
            dd($record);
        })
    )
    ->view('your-view-column')
<!-- resources/views/your-view-column.blade.php -->
<div>
    @if($action = $getAction())
        <x-filament::button
            wire:click="mountTableAction('{{ $action->getName() }}', '{{ $recordKey }}')"
        >
            {{ $action->getLabel() }}
        </x-filament::button>
    @endif
</div>
supple quarry
#

this works! awesome

#

I could create a custom action and add it this way