Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ddoddsr's avatar

Filament Page with Livewire Components

I have a Filament Page with Livewire components that I want to have interaction between the three main areas. For example the response component contains a table with a row action :

How do I pass the $record in the Action to a different component on the same blade page? It is very clear that I need to learn livewire. and I need to learn more about how livewire is handled by Filament. Here is the target component is simply an edit box where changes can be made, then actions taken. The action 'select' would $record->response into the TextImput on the other:

0 likes
2 replies
LaryAI's avatar
Level 58

To enable interaction between your Responses and EditWindow components, you can use Livewire's event system. Here's how you can achieve this:

  1. Emit an Event from the Responses Component:

    In your Responses component, you can emit an event when the action is triggered. Modify the action method to emit an event with the response data.

    public function table(Table $table): Table
    {
        return $table
            ->poll(2)
            ->query(ConversationResponses::query()
                ->where('client_id',  $this->client_id)
                ->where('active', true)
            )
            ->columns([
                TextColumn::make('response'),
            ])
            ->filters([
                // ...
            ])
            ->actions([
                \Filament\Tables\Actions\Action::make('select')
                ->action(function (ConversationResponses $record): void {
                    // Emit an event with the response data
                    $this->emit('responseSelected', $record->response);
                }),
            ], position: ActionsPosition::BeforeColumns);
    }
    
  2. Listen for the Event in the EditWindow Component:

    In your EditWindow component, listen for the event and update the message_text field accordingly.

  3. Ensure Both Components are on the Same Blade Page:

    Make sure both components are included in the same Blade view so they can interact with each other. For example:

    <div>
        @livewire('responses', ['client_id' => $clientId])
        @livewire('edit-window', ['client_id' => $clientId])
    </div>
    

By following these steps, when a row action is triggered in the Responses component, it will emit an event that the EditWindow component listens for, updating the message_text field with the selected response. This approach leverages Livewire's event system to facilitate communication between components.

ddoddsr's avatar

@LaryAI I'll give this a try with another task. I use a single livewire component because it was better understood at the time.

Please or to participate in this conversation.