Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request]: Mountable Record Action for record #22

Open
eele94 opened this issue Mar 8, 2024 · 4 comments
Open

[Request]: Mountable Record Action for record #22

eele94 opened this issue Mar 8, 2024 · 4 comments
Labels
v3 Planned for v3

Comments

@eele94
Copy link

eele94 commented Mar 8, 2024

What happened?

Would be awesome to be able to add actions(e.g. tableactions) to the View

This way would be maybe doable to add comment functionality through a package like this
https://github.com/parallax/filament-comments

I tried to make it working, but am failing to implement it in a clean way..

How to reproduce the bug

Package Version

2.6.1

PHP Version

8.3

Laravel Version

10.0

Which operating systems does with happen with?

No response

Which browsers does with happen with?

No response

Notes

No response

@eele94 eele94 added the bug Something isn't working label Mar 8, 2024
@mokhosh mokhosh added v3 Planned for v3 and removed bug Something isn't working labels Mar 8, 2024
@mokhosh
Copy link
Owner

mokhosh commented Mar 8, 2024

I'm thinking of integrating actions for v3.

@CharlieEtienne
Copy link

Hi, I was looking for a way to delete a record, is it currently possible? Or maybe through the edit modal?

@mokhosh
Copy link
Owner

mokhosh commented Mar 16, 2024

@CharlieEtienne Yes, it's not super elegant, but you can do it in the edit modal like this:

use Filament\Forms\Components\Actions;
use Filament\Forms\Components\Actions\Action;

protected function getEditModalFormSchema(?int $recordId): array
{
    return [
        Actions::make([
            Action::make('delete')
                ->icon('heroicon-m-x-mark')
                ->color('danger')
                ->requiresConfirmation()
                ->action(function () use ($recordId) {
                    static::$model::find($recordId)->delete();

                    $this->dispatch('close-modal', id: 'kanban--edit-record-modal');
                }),
        ]),
    ];
}

Hopefully I'll create more elegant ways of doing this in v3.

@CharlieEtienne
Copy link

CharlieEtienne commented Mar 17, 2024

Thanks, it's working.
I just have one problem but I think it's not related: after I delete a record, the page loses scrollbar and I can't scroll up or down anymore. It's probably related to filament itself because I have the same problem with another plugin.
EDIT: Found it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v3 Planned for v3
Projects
None yet
Development

No branches or pull requests

3 participants