© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
Igor

Select with relationship and custom label

I am using a select component, but I am facing an issue when I try to customize the query to only show active items. In this case, my custom label is not being used and instead, the ID is being shown as the label. However, when I remove the custom query, my custom label is used. I am not sure what I am doing wrong. Can you please help me with this issue?

                        Forms\Components\Select::make('agente_id')
                            ->columnSpan(2)
                            ->default(Request::query('agente'))
                            ->label('Agente')
                            ->relationship(
                                name: 'agentesRelated',
                                modifyQueryUsing: fn (Builder $query) => $query->active()
                            )
                            ->getOptionLabelFromRecordUsing(fn (Agente $record) => view('agenteSelectItem', $record)->render())
                            ->searchable(['nome'])
                            ->allowHtml()
                            ->native(false)
                            ->live(onBlur: true)
                            ->required(),
                        Forms\Components\Select::make('agente_id')
                            ->columnSpan(2)
                            ->default(Request::query('agente'))
                            ->label('Agente')
                            ->relationship(
                                name: 'agentesRelated',
                                modifyQueryUsing: fn (Builder $query) => $query->active()
                            )
                            ->getOptionLabelFromRecordUsing(fn (Agente $record) => view('agenteSelectItem', $record)->render())
                            ->searchable(['nome'])
                            ->allowHtml()
                            ->native(false)
                            ->live(onBlur: true)
                            ->required(),
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

Filament Select with Relationship: Custom Label for titleAttribute Options
FilamentFFilament / ❓┊help
14mo ago
Customizing option label from select with relationship
FilamentFFilament / ❓┊help
3y ago
Form Select relationship with custom search
FilamentFFilament / ❓┊help
11mo ago