@davidmarsmalow When you create a record and choose a room, everything works fine because the room has no active rentals yet.
But after saving, that room now has a rental linked to it. So when you go to edit the record, your modifyQueryUsing filter hides that room (since it now has a rental). This makes the select unable to find it — and instead of showing the room name, it just shows the ID.
To ensure the selected room always appears in the list (even if it has an active rental) you can use ->options() instead of ->relationship(). This gives you full control over which rooms are shown, allowing you to include the selected room manually when editing a record.
Forms\Components\Select::make('room_id')
->label('Room')
->options(function ($state) {
$query = \App\Models\Room::query()
->whereDoesntHave('rentals', fn ($q) =>
$q->where('status', RentalStatus::ACTIVE)
);
// Always include the selected room (for edit pages)
if ($state) {
$query->orWhere('id', $state);
}
return $query->pluck('name', 'id');
})
->searchable()
->preload()
->required()
->disabledOn('edit');