F
Filamentβ€’2mo ago
ericmp

TextColumn action->button not working as expected

Tables\Columns\TextColumn::make('asdas')
->label('See 2 items')
->action(
Tables\Actions\Action::make('test')
->button() // it doesnt show it as btn, should it?
->modalContent(fn (Response $record) => view('test', [
'field' => [],
]))
->modalFooterActions(fn () => [])
,
)
Tables\Columns\TextColumn::make('asdas')
->label('See 2 items')
->action(
Tables\Actions\Action::make('test')
->button() // it doesnt show it as btn, should it?
->modalContent(fn (Response $record) => view('test', [
'field' => [],
]))
->modalFooterActions(fn () => [])
,
)
i see like this (see image), but i expected it to be shown as a btn with the primary color as bg , but it doesnt
No description
Solution:
Ah that's why. ->action() adds a button and they can't be nested. So that doesn't work then. I guess you need a custom column then.
Jump to solution
16 Replies
ericmp
ericmpβ€’2mo ago
bump ^^
Dennis Koch
Dennis Kochβ€’2mo ago
Column actions don't render any link or button. They are an action for the whole clickable area.
ericmp
ericmpβ€’2mo ago
oh, yeah true hmmm so how you'd achieve it to make it look like a btn? πŸ€” maybe a custom view there, or what? if it's a custom view not sure how to trigger a modal there yet any ideas?
Dennis Koch
Dennis Kochβ€’2mo ago
Hacky way: ->formatStateUsing(fn () => new HtmlString(Blade::render('<x-filament::button>Button</x-filament::button>)). Cleaner way: View file πŸ˜…
ericmp
ericmpβ€’2mo ago
yeah 🫣 using the hacky way, but it doesnt trigger the modal
No description
Dennis Koch
Dennis Kochβ€’2mo ago
You still have the ->action() part?
ericmp
ericmpβ€’2mo ago
yes
Dennis Koch
Dennis Kochβ€’2mo ago
Did it work before?
ericmp
ericmpβ€’2mo ago
yes wait, the format state using should be set in the action or in the textcolumn? ive set it in the textcolumn
Dennis Koch
Dennis Kochβ€’2mo ago
In the text column. Hm. Maybe some logic inside the button component than breaks this? I am not sure what's the best approach then.
ericmp
ericmpβ€’2mo ago
no console errors hmmm i guess the btn doesnt have any onclick action attached or smth
Dennis Koch
Dennis Kochβ€’2mo ago
It should be on the column. That's why you have ->action on the column
ericmp
ericmpβ€’2mo ago
okay i found something wierd. there is 2 btns
No description
ericmp
ericmpβ€’2mo ago
the above one has the wire:click
No description
Solution
Dennis Koch
Dennis Kochβ€’2mo ago
Ah that's why. ->action() adds a button and they can't be nested. So that doesn't work then. I guess you need a custom column then.
ericmp
ericmpβ€’2mo ago
ohh. okay yeah. ill do the plan b hehe - custom column thanks dennnnnnis (: