filament icon indicating copy to clipboard operation
filament copied to clipboard

Refactor select component to use array of objects for optionsRefactor…

Open pxlrbt opened this issue 2 years ago • 2 comments

Addressing the issue of non-sortable select options.

Should work for ->options()->searchable() and ->relationship()->searchable(). The only limitation is ->options()->searchable() when searching, as these results are ordered client side via FuseJS.

Forms\Components\Select::make('test')
    ->searchable()
    ->options([
        3 => 'First entry',
        1 => 'Second entry',
        2 => 'Third entry',
    ]),
Forms\Components\Select::make('blog_author_id')
    ->relationship('author', 'name', fn ($query) => $query->orderByDesc('id'))
    ->getOptionLabelFromRecordUsing(fn ($record) => $record->name . ' (' . $record->id . ')')
    ->searchable()

Fixes #3268

pxlrbt avatar Aug 02 '22 09:08 pxlrbt

I am assuming this would be needed for MultiSelect as well?

MACscr avatar Aug 08 '22 17:08 MACscr

I am assuming this would be needed for MultiSelect as well?

MultiSelect instanceof Select === true

danharrin avatar Aug 08 '22 17:08 danharrin

@pxlrbt, what's required for this PR to move forward? 😊

zepfietje avatar Aug 22 '22 13:08 zepfietje

@zepfietje This is only waiting on a thorough review and some feedback from @danharrin. I only set it on "draft" so it's not merged "too quickly" 😅

pxlrbt avatar Aug 23 '22 05:08 pxlrbt

@pxlrbt could you resolve merge conflicts?

zepfietje avatar Sep 02 '22 15:09 zepfietje

I've just fixed the merge conflicts @pxlrbt, could you double check it all still works as intended before I give it a review?

danharrin avatar Sep 08 '22 11:09 danharrin

Sorry, didn't have the time this week and will be on vacation the next two weeks.

pxlrbt avatar Sep 16 '22 19:09 pxlrbt