filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
19.01k stars 2.94k forks source link

The column action doesn't work if a closure is used as parameter #6542

Closed plusquamperfekt closed 1 year ago

plusquamperfekt commented 1 year ago

Package

filament/filament

Package Version

v2.17.40

Laravel Version

v10.11.0

Livewire Version

v2.12.3

PHP Version

PHP 8.2.4

Problem description

The modal is not displayed if a closure is used as a parameter in action().

Tables\Columns\TextColumn::make('date_of_birth')
    ->action(function (People $record): Tables\Actions\Action {
        return Tables\Actions\Action::make('dateOfBirthAction')
            ->form([
                TextInput::make('date_of_birth')
                     ->default($record->date_of_birth)
            ]);
    })

Expected behavior

As in the following example, a modal should open.

Tables\Columns\TextColumn::make('name')
    ->action(
        Tables\Actions\Action::make('nameAction')
            ->form(function (People $record): array {
                return [
                    TextInput::make('name')
                        ->default($record->name)
                 ];
        })
    ),

Steps to reproduce

  1. Clone my the repository. https://github.com/plusquamperfekt/filament-table-column-action

  2. Install composer packages composer install

  3. Run vite npm install && npm run dev

Reproduction repository

https://github.com/plusquamperfekt/filament-table-column-action

Relevant log output

No response

danharrin commented 1 year ago

Thanks, but this is deliberate. If a closure is passed, we assume this is a function to run one-time when the column is clicked. Kinda shorthand for if you dont need to open a modal, just run a function

kerrymoralee4099 commented 3 months ago

@plusquamperfekt I'd be interested to know if you ever worked around this and what your solution looked like.