Hidden function responsible for error

Hey, How can I make this code more robust:
TextInput::make('delivered_quantity')
->numeric()
->hidden(fn (Get $get) => ! $get('../../sent')),
TextInput::make('delivered_quantity')
->numeric()
->hidden(fn (Get $get) => ! $get('../../sent')),
The above code sometimes gives an error: Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization However when i comment out the hidden. It works Can I make the Closure more robust to fix this ?
Solution:
I 'solved' this by wrapping it in a try catch and when in the cath, always return false
Jump to solution
4 Replies
JJSanders
JJSandersOP12mo ago
Bumping this. Anyone?
Sjoerd24
Sjoerd2412mo ago
I don't know what data you exactly need from a parent form, but maybe you can better use livewire sth like this: ->hidden(function(Component $livewire) { return $livewire->data['sent_field']; })
JJSanders
JJSandersOP11mo ago
I need to know the status from the order in order to decide if the field should be visible I also tried this solution:
->hidden(fn ($record): bool => !$record->sent)
->hidden(fn ($record): bool => !$record->sent)
But this also gives me this error: Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization
Solution
Azorky
Azorky11mo ago
I 'solved' this by wrapping it in a try catch and when in the cath, always return false
Want results from more Discord servers?
Add your server