AntV
AntV
FFilament
Created by AntV on 3/29/2025 in #❓┊help
`Typed property Filament...Component::$container must not be accessed before init` from custom field
I have a custom field that I am calling from within the form scheme of a panel. Inside it I have cave a computed property that returns some inputs, I would like to make use of filament's form components though, to keep everything more consistent. If however I do so, I am greeted with the following error: Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization The code that produces the output is this:
public function makeFilterField($filter) {
if (!$this->getCategoryId()) {
return null;
}
$field = match ($filter['type']) {
FilterType::text => \Filament\Forms\Components\TextInput::make("filters.{$filter['id']}")->label($filter['name']),
FilterType::number => \Filament\Forms\Components\TextInput::make("filters.{$filter['id']}")->label($filter['name'])->numeric(),
default => \Filament\Forms\Components\TextInput::make("filters.{$filter['id']}")->label($filter['name']),
};
return $field;
}
public function makeFilterField($filter) {
if (!$this->getCategoryId()) {
return null;
}
$field = match ($filter['type']) {
FilterType::text => \Filament\Forms\Components\TextInput::make("filters.{$filter['id']}")->label($filter['name']),
FilterType::number => \Filament\Forms\Components\TextInput::make("filters.{$filter['id']}")->label($filter['name'])->numeric(),
default => \Filament\Forms\Components\TextInput::make("filters.{$filter['id']}")->label($filter['name']),
};
return $field;
}
It is called within a blade component that looks like this:
<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
<div x-data x-init="">
@foreach ($getFilters() as $filter)
{{ $makeFilterField($filter) }}
@endforeach
</div>
</x-dynamic-component>
<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
<div x-data x-init="">
@foreach ($getFilters() as $filter)
{{ $makeFilterField($filter) }}
@endforeach
</div>
</x-dynamic-component>
Is there a way to perhaps block this until the child components are ready? I tried adding a flag and waiting for afterStateHydrated, but it did not help
2 replies
FFilament
Created by AntV on 5/28/2023 in #❓┊help
KeyValue field breaks json into array of characters
14 replies