F
Filament5mo ago
swilla

Error with widget in a blade view

Unable to find component: [Filament\Widgets\WidgetConfiguration] I tried this in a normal blade view, and a Livewire component. I have confirmed that the class exists. Livewire Component:
<?php

namespace App\Livewire;

use App\Models\Community;
use App\Models\Metric;
use Livewire\Component;

class ShowEmbed extends Component
{
public function render(Community $community, Metric $metric)
{
if (! request()->hasValidSignature()) {
abort(401);
}

return view('livewire.show-embed', [
'community' => $community,
'metric' => $metric,
]);
}
}
<?php

namespace App\Livewire;

use App\Models\Community;
use App\Models\Metric;
use Livewire\Component;

class ShowEmbed extends Component
{
public function render(Community $community, Metric $metric)
{
if (! request()->hasValidSignature()) {
abort(401);
}

return view('livewire.show-embed', [
'community' => $community,
'metric' => $metric,
]);
}
}
Blade View:
<div>
@livewire(App\Filament\Widgets\CascadingMetric::make([
'metric' => $metric,
'community' => $community,
]))
</div>
<div>
@livewire(App\Filament\Widgets\CascadingMetric::make([
'metric' => $metric,
'community' => $community,
]))
</div>
Layout File:
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">

<meta name="application-name" content="{{ config('app.name') }}">
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>{{ config('app.name') }}</title>

<style>
[x-cloak] {
display: none !important;
}
</style>

@filamentStyles
@vite('resources/css/app.css')
</head>

<body class="antialiased">
{{ $slot }}

@filamentScripts
@vite('resources/js/app.js')
</body>
</html>
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">

<meta name="application-name" content="{{ config('app.name') }}">
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>{{ config('app.name') }}</title>

<style>
[x-cloak] {
display: none !important;
}
</style>

@filamentStyles
@vite('resources/css/app.css')
</head>

<body class="antialiased">
{{ $slot }}

@filamentScripts
@vite('resources/js/app.js')
</body>
</html>
2 Replies
swilla
swilla4mo ago
This error occurs when you use "make()" on widgets in a blade file. I was able to get around this by having a Livewire component send all the same variables to the widgets view.
awcodes
awcodes4mo ago
Widgets are livewire components and therefore cannot be instantiated via something like make(). So just use @livewire(WidgetName::class, [data])