F
Filament16mo ago
xy

New widget not working

Im using a new widget for a render hook and seeing this error:
Using $this when not in object context
Using $this when not in object context
Widget code:
<x-filament-widgets::widget class="fi-filament-info-widget">

</x-filament-widgets::widget>
<x-filament-widgets::widget class="fi-filament-info-widget">

</x-filament-widgets::widget>
<?php

namespace App\Filament\Widgets;

use Filament\Widgets\Widget;

class Sidebar extends Widget
{
protected static string $view = 'filament.widgets.sidebar';
public array $actions = [];

public function mount(): void
{
$this->actions = [];
}

public function getColumnSpan(): int | string | array
{
return [];
}

public static function getSort(): int
{
return -1;
}
}
<?php

namespace App\Filament\Widgets;

use Filament\Widgets\Widget;

class Sidebar extends Widget
{
protected static string $view = 'filament.widgets.sidebar';
public array $actions = [];

public function mount(): void
{
$this->actions = [];
}

public function getColumnSpan(): int | string | array
{
return [];
}

public static function getSort(): int
{
return -1;
}
}
5 Replies
xy
xyOP16mo ago
When i remove
<x-filament-widgets::widget class="fi-filament-sidebar-widget">
<x-filament-widgets::widget class="fi-filament-sidebar-widget">
from the blade file the error disappears?
awcodes
awcodes16mo ago
Well you code doesn’t look like it’s actually trying to do anything. But you definitely need to call parent::mount() inside your mount method.
xy
xyOP16mo ago
I haven't done any logic work yet. Still getting the following error for my via after adding
parent::mount();
parent::mount();
Using $this when not in object context
Using $this when not in object context
Dennis Koch
Dennis Koch16mo ago
Please see #✅┊rules and share the Flare error
xy
xyOP16mo ago
Fixed by adding HasActions
Want results from more Discord servers?
Add your server