Any way to retrieve the current active tab from a tabs form component? #11375
-
PackagePanel builder Package Versionv3.2 How can we help you?Hi everyone. I need to get the current tab of my tab component when the create method runs.
Now this tab returns the default value but is not getting synced with the URL param, and the request()->query() is always null. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 7 replies
-
I have spent about 3 hours trying to figure this out in 20 different ways but without success. |
Beta Was this translation helpful? Give feedback.
-
The final solution was to run some js within the filament class, so it should evaluate the query string while creating the form and fetch the current tab from it. Here is the code.
There might be a better solution to call the js from the front end and then call the create() method via $wire. Still, as this form is loaded every time the page loads but is only executed occasionally, the extra round trip is not a big deal. |
Beta Was this translation helpful? Give feedback.
-
I am currently facing kinda similar issue. Is there any way how to change current tab apart from clicking the actual tab button? I am using basic anchor with tab in query string, but I hoped I could figure things out with just Livewire or Alpine. |
Beta Was this translation helpful? Give feedback.
-
$this->form->getLivewire()->tab Easiest and most elegant method to fetch the current tab |
Beta Was this translation helpful? Give feedback.
-
I've solved using ->url(fn($livewire) => self::getUrl('edit', [$livewire->activeTab])) ex. ->emptyStateActions([
Action::make('create')
->label(fn($livewire) => "Edit")
->url(fn($livewire) => self::getUrl('edit', [$livewire->activeTab]))
->icon('heroicon-m-plus')
->button(),
]) |
Beta Was this translation helpful? Give feedback.
The final solution was to run some js within the filament class, so it should evaluate the query string while creating the form and fetch the current tab from it.
Here is the code.