FilamentF
Filament3y ago
Vp

Multiple select options allow custom logic

I've already asked this one but cannot find it anymore, so here I am asking again with different topic.

Is there any plan this select components accepts all my logic and render the item correctly?

Base on my below code, If I used like this the name is displaying correctly in the select (chip...let call it chip) but If i try to use primaryAccount() then it cannot display name, only ID is displaying in the chip

But I really need to use my custom logic (scope) in the options..

Any other work around to overcome and use my logic?

Sorry for bad english and thanks in advance

Tables\Actions\Action::make('edit')
    ->mountUsing(fn (Forms\ComponentContainer $form, Customer $record) => $form->fill([
        'approver' => $record->id,
        'name' => $record->name.' ('.$record->member_id.')',
        'child' => Customer::where('approver', $record->id)->pluck('id'),
    ]))
    ->form(function (Customer $record) {
        return [
            Forms\Components\Group::make()
                ->schema([
                    Forms\Components\Hidden::make('approver'),
                    Forms\Components\TextInput::make('name')->disabled(),
                    Forms\Components\Select::make('child')
                        ->multiple()
                        ->required()
                        ->options(
                            Customer::query()
                                ->where('id', '!=', $record->id)
                                ->hasNotChild()
                                // ->primaryAccount()
                                ->active()
                                ->pluck('name', 'id')
                        )
                        ->getOptionLabelUsing(fn ($value): ?string => Customer::find($value)?->name)
                        ->searchable(),
                ])
                ->columns(2),
        ];
    })
Screenshot_from_2023-06-02_10-18-32.png
Screenshot_from_2023-06-02_10-18-54.png
Was this page helpful?