© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•4mo ago•
1 reply
nowak

Dynamic selectablePlaceholder closure does not have the desired effect

I have a select field, that I want to not show the selectablePlaceholder "x" icon, on specific conditions, which depend on the state of other fields in my form.

When I use
->selectablePlaceholder(false)
->selectablePlaceholder(false)
, the "x" icon is removed as expected, but when I use this:
->selectablePlaceholder(function (Get $get, ?string $state) {
  $groupId = (int) ($get('group_id') ?? 0);
  if ($groupId) {
    $singleUsers = User::query()
      ->whereHas('groups', fn($q) => $q->whereKey($groupId))
      ->limit(2)
      ->get();
    if (count($singleUsers) === 1 && $singleUsers->contains('id', $state)) {
      return false;
    }
  }
  return true;
})
->selectablePlaceholder(function (Get $get, ?string $state) {
  $groupId = (int) ($get('group_id') ?? 0);
  if ($groupId) {
    $singleUsers = User::query()
      ->whereHas('groups', fn($q) => $q->whereKey($groupId))
      ->limit(2)
      ->get();
    if (count($singleUsers) === 1 && $singleUsers->contains('id', $state)) {
      return false;
    }
  }
  return true;
})

whenever the closure returns
false
false
, the selectablePlaceholder "x" icon is still visible which is not expected, and whenever the closure returns
true
true
, the selectablePlaceholder "x" icon is visible as expected.

Is selectablePlaceholder not meant to be dynamic? I.e. does it only set the selectablePlaceholder icon on first render/mount, or can it be set dynamically?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Closure Upload Folder dynamic
FilamentFFilament / ❓┊help
2y ago
Infolist Grid column does not support Closure?
FilamentFFilament / ❓┊help
2y ago
Select::selectablePlaceholder(false) not working with relationships
FilamentFFilament / ❓┊help
2y ago
Target Closure not Instantiable
FilamentFFilament / ❓┊help
3y ago