Custom Modal View for ViewAction
Is it possible to load a custom view into the ViewAction Modal so I can render the data differently?
Background: Because the default ViewAction just takes the Form and disables all Inputs but it doesn’t work well for Multiselects / Tag Inputs so I would like to change that for a better UI.
Thank you! 🙏
36 Replies
No, but you can make your own action to either show a view in a modal or redirect to a custom page to view the record.
Thanks!
Can I use the modal component from filament so I don’t need to create my own modal and logic for it?
You can just use
Action::make()->modalContent()
Yes, the Action class support modals out of the box.
Oh nice, thank you! 🙏
Hi Dennis, just tried this, but the modal doesn't show up right now:
I think as the docs say, every action needs a
->action(),
but I don't understand how this needs to be setup if you just want a modal with extra information of that record and a close button. From my understanding there isn't a real "action" behind it.You need an ->action()
yes, but ->action() needs a callback and as I said above this should only display information of the record
That's fine, but you still need an action for it to render
fn() => ''
so
ah okay, and how can I access the $record inside the modal view?
if you have a custom view i.e. view-incident then you can just get it within there with the closures $get i.e.
okay, sorry for my noob questions but you mean inline php inside blade?
so {{ $evaluate(fn ($get) => $get('my_field')) }}
in here
view('filament.modals.view-incident')
you are calling a custom blade view
so {{ $evaluate(fn ($get) => $get('my_field')) }}
inside filament\modals\view-incident.blade.php
okay, I get
Undefined variable $evaluate
and I think it would be better if I could pass $record to the view so I can do things like $record->title etc.
Can I somehow achieve this?->modalContent(fn ($record) => view('filament.modals.view-incident', ['record' => $record]))
evaluation only works in things like form fields and table columnsAn action has a form? So assumed it was available
yeah, but not quite
Works, thank you 🙏
Is
->action(fn() => '')
the right way for a "view only" modal? Because I still get the submit + cancel button and only need a close button.you can use ViewAction::make( instead of Action::make(
okay, but then I also get all disabled form elements. I would like to just have my custom view rendered inside the modal.
you have form elements but no action?
how are you supposed to submit the form without a submit button
I think you got me wrong. I've a IncidentResource and everything works just fine with it. The only thing I want to do differently is to have a ViewAction where I can customize the content of it. Because the default disabled form elements don't quite fit for this use case.
oh ok
just pass
->form([])
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
it is not
and what you have there is probably going to cause problems
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
have you tried filters or actions in the nested table
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
yes, check the docs
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
no i dont mean that
i mean you can open a modal by clicking on the content of any cell
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Filament
Getting started - Columns - Table Builder - Filament
The elegant TALL stack table builder for Laravel artisans.
you can use an iconcolumn
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
how about adding the action to the id column
and instead of using a textcolumn, use a viewcolumn where you render the state and the icon together
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View