ViewAction on resource's table listing page

Hi,
I have a model Estimate that has relationship to other model User. I want from ListEstimate page to have action that will open user info in a modal window (slideover). How to achive that? What I tried so far didn't work:

Tables\Actions\ViewAction::make('view-user')
  ->label('Show user')
  ->slideOver(true)
  ->record(fn ($record) => User::find($record->user_id));
Solution
I've manage to find the solution to my problem using mountUsing() method on an action by inspecting how ViewAction works in the Filament. This is my solution:

Tables\Actions\Action::make('view-linked-user')
  ->label('Show user')
  ->slideOver(true)
  ->mountUsing(function (Form $form, Estimate $record) {
      $user = User::find($record->user_id);
      $form->model($user);
      $form->operation('view');
      $form->disabled(true);
      $form->fill($user->toArray());
  })
  ->form(function (Estimate $record): array {
      return [...UserForm::fields()];
  });


In my form() method I am calling my custom class UserForm that define fields for this action and for my UserResource class.
Was this page helpful?