Customizing options labels in getRecordSelect() with additional information

->headerActions([
    AttachAction::make()
        ->form(fn (AttachAction $action): array => [
            $action
                ->recordSelect(function ($select) {
                    $select->options(function () use ($select) {
                        $options = $select->getOptions();
                        $formattedOptions = [];
                        foreach ($options as $value => $label) {
                            $model = Lotto::find($value);
                            $formattedLabel = 'Test label';
                            $formattedOptions[$value] = $formattedLabel;
                        }
                        return $formattedOptions;
                    });
                    return $select;
                })
                ->preloadRecordSelect()
                ->getRecordSelect()
                ->label('Lotto botanica'),
            Forms\Components\TextInput::make('grammi_utilizzati')
                ->required()
                ->numeric()
                ->minValue(1)
                ->mask(fn (TextInput\Mask $mask) => $mask
                    ->numeric(),
                )
                ->suffix('g'),
        ])
])

I was trying to customize the labels of the options with this code, but I'm having trouble.
What am I doing wrong?

Thank you.
Was this page helpful?