#ViewAction behaviour differs between ListingPage and BaseWidget

1 messages · Page 1 of 1 (latest)

mint forge
#

Hello,

The ViewAction redirects to the view page when I click on it from the listing page.
But when I use it in a BaseWidget context, it opens an empty modal. While I would like to be redirected too.

Here is my OfferTable:

class OfferTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns(self::getColumns())
            ->recordActions(self::getRecordActions());
    }

    public static function getRecordActions(): array
    {
        return [
            ViewAction::make(),
            EditAction::make(),
        ];
    }
    // ...
}

Here is my widget:

<?php

namespace App\Filament\Widgets\Tables;

class LatestOffers extends BaseWidget
{
    protected static bool $isLazy = false;

    public function table(Table $table): Table
    {
        $query = OfferResource::getEloquentQuery();
        $actions = OfferTable::getRecordActions();
        $columns = OfferTable::getColumns();

        return $table
            ->query($query)
            ->recordActions($actions)
            ->columns($columns);
    }
}

I would have liked to reuse the getRecordActions function... Am I forced to define an Action::make()->url(...)?
Thanks for your help!!

old horizonBOT
#

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

lapis glacier
#

Afaik, the widget is always going to default to trying to open a modal edit, so you'll need to define an action with something like ...

EditAction::make()
  ->url(fn (Offer $record) => OfferResource::getUrl('edit', ['record' => $record]))
misty sentinel
#

ViewActions are meant to be used in tables and are preconfigured in that scenario. That's why they are not working in a widget.