Skip to content

Possible access resourceItem in ActionButton withConfirm() #1467

Answered by WillieOng-HK
WillieOng-HK asked this question in Q&A
Discussion options

You must be logged in to vote

I found the solution

->withConfirm(
    title: 'Delete Role Confirmation',
    content: 'Are you sure you want to delete all roles of this user?',
    button: 'Confirm Delete',
    fields: fn (Model $item) => [
        UI\Fields\Hidden::make('resourceItem')->setValue($item->getKey()), // ADD THIS LINE
    ],
    name: static fn (mixed $item, ActionButtonContract $ctx): string => "delete-user-role-{$ctx->getData()?->getKey()}"
);

then you can get the resourceItem using $this->getItem()

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by WillieOng-HK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant