Modify Label Options in RelationManager attach action
Hello
I'm trying to modify the options in attach action form inside a Relation Manager without success.
I'm using recordSelect & getOptionLabelFromRecordUsing
My code attached
Any help will be appreciate
Thanks
I'm trying to modify the options in attach action form inside a Relation Manager without success.
I'm using recordSelect & getOptionLabelFromRecordUsing
My code attached
Any help will be appreciate
Thanks

Solution
The way I did it last time was like so:
Tables\Actions\AttachAction::make()
->label('Add Part')
->modalHeading('Add Template Part to Document')
->icon('heroicon-o-plus')
->form(fn (AttachAction $action): array => [
Forms\Components\Select::make('recordId')
->hiddenLabel()
->label('Select Part to Add')
->options(fn (RelationManager $livewire) => \App\Models\ContractTemplatesParts::query()->whereNotIn('part', $livewire->ownerRecord->parts->pluck('part'))
->get()
->mapWithKeys(function ($item) {
$html = $item->is_global ? '<span class="text-green-500 font-bold">Global</span> - ' : '';
return [$item->id => $html.implode(' - ', ['title' => $item->title, 'type' => $item->type, 'part' => $item->version])];
})
->toArray()
)
->allowHtml(),
]), Tables\Actions\AttachAction::make()
->label('Add Part')
->modalHeading('Add Template Part to Document')
->icon('heroicon-o-plus')
->form(fn (AttachAction $action): array => [
Forms\Components\Select::make('recordId')
->hiddenLabel()
->label('Select Part to Add')
->options(fn (RelationManager $livewire) => \App\Models\ContractTemplatesParts::query()->whereNotIn('part', $livewire->ownerRecord->parts->pluck('part'))
->get()
->mapWithKeys(function ($item) {
$html = $item->is_global ? '<span class="text-green-500 font-bold">Global</span> - ' : '';
return [$item->id => $html.implode(' - ', ['title' => $item->title, 'type' => $item->type, 'part' => $item->version])];
})
->toArray()
)
->allowHtml(),
]),