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
No description
Solution:
The way I did it last time was like so: ```php Tables\Actions\AttachAction::make() ->label('Add Part')...
Jump to solution
3 Replies
Juan Duarte Molina
Juan Duarte MolinaOPβ€’7mo ago
Any hint will be appreciate ...πŸ˜€ πŸ™ Any workaround? thanks.
Solution
toeknee
toekneeβ€’7mo ago
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(),
]),
Juan Duarte Molina
Juan Duarte MolinaOPβ€’6mo ago
Thank you , that code do the trick ... the πŸ₯³
Want results from more Discord servers?
Add your server