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

marcw's avatar
Level 2

Edit model in modal instead of page

I would like to edit a model in a modal instead of a page as seen in demo page > blog > autors. I inspected the source code but couldn't find out how achieve this behaviour.

0 likes
6 replies
tisuchi's avatar
tisuchi
Best Answer
Level 70

@marcw Here is how you can use the modal instead of using the edit page directly.

  1. Go to the Resource page. e.g. app/Filament/Resources/Blog/AuthorResource.php
  2. Just call modal() in the edit action. e.g. Tables\Actions\EditAction::make()->modal(). https://github.com/filamentphp/demo/blob/main/app/Filament/Resources/Blog/AuthorResource.php#L93

It should be enough for the modal.

⚠️ Caution:

If you link the EditPage in your getPagest() method in the resource class, it won't work. You should remove/comment out from there.

1 like
lourbert's avatar

@tisuchi return me an error Method Filament\Tables\Actions\EditAction::modal does not exist.

marcw's avatar
Level 2

Wow, as easy as this. Works great. Thank you so much. Also for the caution hint.

1 like
jd5am's avatar

Hi all - I'm not sure if this is a bug or my implementation, but:

click row 1 of record to edit. SlideOver is displayed with correct data. Click Cancel or the X of the slideOver.

click row 2 of record to edit. SlideOver is displayed with data from row 1. This is of course incorrect.

Perform the same 2 tests but instead of Cancel, click Save changes and the correct data is returned in the modal for both tests.

Any help greatly appreciated!

Below is a my standard filament resource:

Laravel Framework v12.19.3

Filament v3.2


class BusinessStageResource extends Resource { use HasModeFieldTrait, HasAdminSettingField;

protected static ?string $model = BusinessStage::class;

protected static ?string $modelLabel = 'Business Stage';
protected static ?string $pluralModelLabel = 'Business Stages';

protected static ?string $navigationGroup = 'Core Tables';
protected static ?string $navigationLabel = 'Business Stages';

protected static ?int $navigationSort = 1;

public static function getEloquentQuery(): Builder
{
    $settings = app('settings');

    $query = parent::getEloquentQuery()
    ->whereHas('adminSetting', function (Builder $q) {
        $q->activeAppointedRepresentatives();
    });

    return $query->orderBy('admin_setting_id')->orderBy('id', 'desc');
}

public static function form(Form $form): Form
{
    $settings = app('settings');

    return $form
        ->schema([
            Section::make()
                ->schema([
                    Grid::make(1)
                        ->schema([
                            (new self())->adminSettingSelect($settings),
                            TextInput::make('business_stage')
                                ->label('Business Stage')
                                ->placeholder('Business Stage')
                                ->validationAttribute('business stage')
                                ->required()
                                ->maxLength(191)
                                ->unique(
                                    ignoreRecord: true,
                                    modifyRuleUsing: HasAdminSettingField::adminSettingUniqueRule($settings)
                                ),
                            (new self())->modeField(),
                        ]),
                ]),
        ]);
}

public static function table(Table $table): Table
{
    $settings = app('settings');

    return $table
        ->defaultPaginationPageOption(25)
        ->columns([
            TextColumn::make('id')
                ->toggleable()
                ->label('ID')
                ->sortable(),
            (new self())->adminSettingTextColumn('adminSetting.title', $settings),
            TextColumn::make('business_stage')
                ->label('Business Stage')
                ->sortable()
                ->searchable(),
            (new self())->modeColumn(),
            TextColumn::make('created_at')
                ->dateTime()
                ->sortable()
                ->toggleable(isToggledHiddenByDefault: true),
            TextColumn::make('updated_at')
                ->dateTime()
                ->sortable()
                ->toggleable(isToggledHiddenByDefault: true),
        ])
        ->modifyQueryUsing(function (Builder $query) use ($settings) {
            if ($settings->is_master === 'no') {
                return $query->where('admin_setting_id', $settings->id);
            }
        })
        ->filters([
            (new self())->adminSettingSelectFilter('adminSetting', $settings),
            (new self())->modeFilter(),
        ])
        ->actions([
            Tables\Actions\EditAction::make()
                ->modalWidth(MaxWidth::Large)
                ->slideOver(),
            Tables\Actions\DeleteAction::make(),
        ])
        ->bulkActions([
            Tables\Actions\BulkActionGroup::make([
                Tables\Actions\DeleteBulkAction::make(),
            ]),
        ]);
}

public static function getPages(): array
{
    return [
        'index' => Pages\ListBusinessStages::route('/'),
        // 'create' => Pages\CreateBusinessStage::route('/create'),
        // 'edit' => Pages\EditBusinessStage::route('/{record}/edit'),
    ];
}

}


Please or to participate in this conversation.