Undefined variable $activeTab
Im trying to make tabs in a blade component, but I get this error. Any idea why?
Solution:Jump to solution
Ok, so do you have a
public string $activeTab
property on your Livewire component?16 Replies
Looks like your
$activeTab
variable is undefined
Not sure of the context but maybe $this->activeTab
, in a Livewire component?This is taken straight from the docs.
Could something be wrong with the docs?
Right, I think the docs is just focusing on what it would look like on the Blade side to keep things simple. It really depends on the context though. Are you in a Livewire component?
Can you use the Alpine example instead?
Yah, I am
Solution
Ok, so do you have a
public string $activeTab
property on your Livewire component?I dont
Add it, then use
$this->activeTab
instead in your Blade viewThat removes the error, but it only shows Tab 1:
(Its a custom Dashboard. Not the default that comes with FIlament)
Not sure... what if you remove the
:active="..."
on all tabs. What do you get?Ah, I just cleared the views and its ok now!
Also, how can I show different data on each tab?
I cant find that info on the docs
Yeah the docs are focused on the Tabs part, not the content. 1 sec
You know which tab is active with
$activeTab
, so you can display some <div>
under the tabs and show the one for the active tab.