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(),
0 Replies