FilamentF
Filament13mo ago
Matthew

Using Getters in forms

When using Get $get in forms, and you want to get the value of lets say a component that is AFTER the component that has the getter, it will return null. For example:
TextInput::make('author_name')
    ->label('Author')
    ->disabled()
    ->dehydrated()
    ->formatStateUsing(fn (Get $get) => dd($get('author_id')))
    ->required(),
Hidden::make('author_id')
    ->label('Author')
    ->default(fn () => Auth::id())
    ->required(),

Is this intended? I assume the components in the form are processed linearly, but wouldnt it be better for the Getter to check all the components and not just the ones that "have already been processed"?
Was this page helpful?