Create table header action question...
I'm using just the table builder package and have a quick question:
- When I implement a create record table header action, how do I get the action to return to the list page when done? I have tried using
successRedirectUrl()
...but no redirect occurs. The record is created, but that's it.17 Replies
you can route()->redirect() inside the action()
I don't have and don't need, apparently, any
action()
call. Here's what I have in my table component:
The 'posts.create'
route shows a filament form that, when submitted, creates the new resource, but nothing else...no redirect/return.
I feel like I'm missing something again....have you told it to redirect when the form is submitted?
As noted, I tried to do so via the successRedirectUrl()...but it doesn't appear to work, so I'm either using it incorrectly or there's some other way...? 🤔
I was also just told elsewhere to try to use redirectRoute(), which my IDE doesn't hint/suggest, so I didn't know it was a possibility....and didn't see it when looking through the filament code.
So...I'll try that shortly....
show me where you are submitting the form
it sounds like its not anything related to filament
It may not have anything to do with filament....
Anyway, here's the create() method for my CreatePost form:
so where are you redirecting then?
I tried to redirect from the table component's getTableHeaderActions() method by calling successRedirectUrl() on the action, passing the route that displays the table component.
the action is just a button
it is just an <a>
it sends the user to the create page
the create page is responsible for redirecting the user back
OK. I guess that makes sense...and seems like it should have been obvious. Sorry....
the only time an action will redirect is if it isnt a url()
when it opens a modal or something
Is this the way that you anticipate users of the table-builder to work, then...?
To have the create/edit forms responsible for redirecting to where they need to go...?
With admin panel, it seems like there's the "layer" that ties all these things together nicely, but when using just the table-builder package, then it's on me to know that when I'm done creating, I want to go back to the list...and when I'm done editing, I want to go back to viewing the individual resource, or, perhaps, returning to the list....?
yes thats the whole point
It's 100% up to me to implement that wiring from the create/edit forms....
in the admin panel this is done for you
outside, its a normal laravel app
Alright...so the redirectXyz() methods on the actions....what are they for...?
Is that for when a modal form is used...?
Referring to Filament\Support\Actions\Concerns\CanRedirect
those are for our built-in actions like CreateAction, EditAction. which open modals.