Remove the item selected in another select
I tried this but it deson't work
Group::make([
Forms\Components\Select::make('from_id')
->relationship('from', fn (Builder $query, Get $get) => $query->where('id', '!=', $get('to_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->preload()
->searchable()
->required()
->live(onBlur: true),
Forms\Components\Select::make('to_id')
->relationship('from', fn (Builder $query, Get $get) => $query->where('id', '!=', $get('from_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->preload()
->searchable()
->required()
->live(onBlur: true),
])->columns(2),
Group::make([
Forms\Components\Select::make('from_id')
->relationship('from', fn (Builder $query, Get $get) => $query->where('id', '!=', $get('to_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->preload()
->searchable()
->required()
->live(onBlur: true),
Forms\Components\Select::make('to_id')
->relationship('from', fn (Builder $query, Get $get) => $query->where('id', '!=', $get('from_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->preload()
->searchable()
->required()
->live(onBlur: true),
])->columns(2),
1 Reply