$container must not be accessed before initialization
What happen with this error? I'm trying to set TextInput "title" component at updated() method but this error is showed.
Complete error:
Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization
I need to set title when any field is changed. I used to use afterStateUpdated()
method but this not work in "live".2 Replies
Anyone found the solution?
return $table
->modifyQueryUsing(function ($query) {
$currentUserId = auth()->id();
$query->where(function ($query) use ($currentUserId) {
$query->where('Sender', $currentUserId)
->orWhere('Empfänger', $currentUserId);
});
})
->columns([
Tables\Columns\TextColumn::make('Sender')->numeric()->sortable(),
Tables\Columns\TextColumn::make('Nachricht')->numeric()->sortable(),
])
->filters([
Filter::make('Empfänger')
->form(static function () {
return [
ToggleButtons::make('Empfänger')
->label('Deine Chats')
->options(static function (Get $get) {
$user = auth()->user();
return self::getLast6Chats($user, $get('searchText'));
})
->live()
->inline(),
TextInput::make('searchText')
->label('Suche nach einem Chat')
->live()
->placeholder('Suche nach einem Benutzer...')
->name('searchText'),
];
})
->query(static function (Get $get, $query) {
$empfänger = $get('Empfänger');
$query->where(function ($query) use ($empfänger) {
$query->where('Sender', $empfänger)
->orWhere('Empfänger', $empfänger);
});
}),
trying to use the Empfänger field to edit the query but i get the error
Code formatting would help reading this (#✅┊rules)