Can't get correct URL when saving form

I'm trying to conditionally show a tab based on url name, I have a normal edit resource page with /edit endpoint and another page with custom endpoint that is using Edit Resource. When I'm on /edit endpoint I want to hide some tab and when I'm on custom endpoint I want to show that tab, which works to certain point when it comes to only refreshing the page. If I dump request in visible() method on normal refresh I get multiple "/livewire/update" in dump, but in DOM I can see it has "/app/1/profiles/7/edit" uri (which is okay when I'm simply loading the page, since it's working as intended). However, when submitting the form and dumping request it's as if things break at DOM level and the tab simply gets shown. I also noticed when I change date in some input field the tab gets shown*. I'm not sure if there's another way of doing this, I tried to store things into session but couldn't get it to work correct and it takes some work to manage storing correct values in session. It also seems as if visible() method gets called multiple times for some reason and makes it even more weird to store values into session, since it's firing multiple times for different things. Not sure what to do here anymore, seems like it should be quite simple to implement this, but now it got a bit more complicated.
No description
No description
No description
No description
No description
14 Replies
Thijmen
Thijmen4w ago
Cant you use the ProfileResource::getUrl('edit') ? And when on that url hide it or make it visible Depending on your case
lukaveck1
lukaveck1OP4w ago
Trying to test this out but am having a different problem now: I'm getting "Missing required parameter for [Route: filament.app.resources.profiles.edit] [URI: app/{tenant}/profiles/{record}/edit] [Missing parameter: record]." even though I'm passing $record in correctly and it's having proper values.
No description
lukaveck1
lukaveck1OP4w ago
also tried $record->id even if I manually put in value I keep getting this error. Oh, just noticed I haven't correctly set array as second param in function, will try it out now.
lukaveck1
lukaveck1OP4w ago
When I'm on custom endpoint it returns /edit endpoint
No description
No description
Thijmen
Thijmen4w ago
Hmm I you just want the current url you can use Request::
lukaveck1
lukaveck1OP4w ago
No, that's the problem, because livewire returns
No description
lukaveck1
lukaveck1OP4w ago
No description
lukaveck1
lukaveck1OP4w ago
I also tried if I could somehow get current route name correctly since I'm on custom route, but to no success.
lukaveck1
lukaveck1OP4w ago
No description
lukaveck1
lukaveck1OP4w ago
this returns
No description
lukaveck1
lukaveck1OP4w ago
Bump..
toeknee
toeknee4w ago
Ok so for a vie wor edit page you need to do:
ProfileResource::getUrl('edit', ['record' => $theModelRecord])
ProfileResource::getUrl('edit', ['record' => $theModelRecord])
toeknee
toeknee4w ago
Just saw he is using tenacy too
ProfileResource::getUrl('edit', ['record' => $theModelRecord], true, 'admin', $record->tenant)
ProfileResource::getUrl('edit', ['record' => $theModelRecord], true, 'admin', $record->tenant)
true = isAbsolute admin = the panel $record->tenant = tenant model

Did you find this page helpful?