© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
6 replies
Mark Chaney

Undefined variable in custom field

I have very simple form field that i created that extends the simple placeholder component, which looks like so:
<?php

namespace App\Forms\Components;

use Filament\Forms\Components\Placeholder;

class Alert extends Placeholder
{
    protected string $view = 'forms.components.alert';
    public string $template = 'twui.info-alert';
    public mixed $content;

    public function type($type): static
    {
        $this->template = "twui.{$type}-alert";

        return $this;
    }
}
<?php

namespace App\Forms\Components;

use Filament\Forms\Components\Placeholder;

class Alert extends Placeholder
{
    protected string $view = 'forms.components.alert';
    public string $template = 'twui.info-alert';
    public mixed $content;

    public function type($type): static
    {
        $this->template = "twui.{$type}-alert";

        return $this;
    }
}
and then the view is
<x-dynamic-component :component="$template">
    {{ $getContent() }}
</x-dynamic-component>
<x-dynamic-component :component="$template">
    {{ $getContent() }}
</x-dynamic-component>
Right now though its saying that $template is undefined. This worked fine with laravel 9 and filament v3 alpha, but not anymore since upgrading to the latest stable of both. I dont see any changes with the Placeholder class that I am extending though. Any ideas what I might be missing?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Undefined variable $canSelectPlaceholder using Select in Custom Field
FilamentFFilament / ❓┊help
3y ago
Undefined variable $isSearchOnBlur
FilamentFFilament / ❓┊help
2y ago
Undefined variable $unreadNotificationsCount
FilamentFFilament / ❓┊help
2y ago
Undefined variable $component
FilamentFFilament / ❓┊help
2y ago