Failed to disabled select before another select

Forms\Components\Select::make('from_id')
->relationship(name: 'from',
modifyQueryUsing: fn (Builder $query, Get $get) => $query->where('id', '!=', $get('to_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->preload()
->searchable()
->required()
->live()
->native(false),Forms\Components\Select::make('to_id')
->relationship(name: 'to',
modifyQueryUsing: fn (Builder $query, Get $get) => $query->where('id', '!=', $get('from_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->disabled(function(Get $get) {
return is_null($get('from_id'));
})
->live()
->preload()
->searchable()
->required()
->native(false)
Forms\Components\Select::make('from_id')
->relationship(name: 'from',
modifyQueryUsing: fn (Builder $query, Get $get) => $query->where('id', '!=', $get('to_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->preload()
->searchable()
->required()
->live()
->native(false),Forms\Components\Select::make('to_id')
->relationship(name: 'to',
modifyQueryUsing: fn (Builder $query, Get $get) => $query->where('id', '!=', $get('from_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->disabled(function(Get $get) {
return is_null($get('from_id'));
})
->live()
->preload()
->searchable()
->required()
->native(false)
Firstly to_id select is disabled before selected the from_id i have this code , The problem after select the from_id , to_id is disabled but i can't open the options ?
2 Replies
toeknee
toeknee4w ago
return empty($get('from_id'));
Dennis Koch
Dennis Koch4w ago
I might be wrong, but I think this is still not possible due to limitations we have with the Select library. You can't toggle the ->disabled() state.