diff --git a/packages/forms/src/Components/ModalTableSelect.php b/packages/forms/src/Components/ModalTableSelect.php index 0dd733c571..2d03f85286 100644 --- a/packages/forms/src/Components/ModalTableSelect.php +++ b/packages/forms/src/Components/ModalTableSelect.php @@ -641,6 +641,12 @@ class ModalTableSelect extends Field return $values; } + $state = $this->getState(); + + if (blank($state)) { + return null; + } + if ($this->isMultiple()) { return array_keys($this->getOptionLabels(withDefaults: false)); } diff --git a/packages/forms/src/Components/Select.php b/packages/forms/src/Components/Select.php index d1d7a2749d..f17f5f3397 100644 --- a/packages/forms/src/Components/Select.php +++ b/packages/forms/src/Components/Select.php @@ -1447,6 +1447,11 @@ class Select extends Field implements Contracts\CanDisableOptions, Contracts\Has } $state = $this->getState(); + + if (blank($state)) { + return null; + } + $optionLabels = $this->getOptionLabels(withDefaults: false); if (count($state) > count($optionLabels)) { @@ -1477,14 +1482,18 @@ class Select extends Field implements Contracts\CanDisableOptions, Contracts\Has throw new LogicException("Filament failed to validate the [{$this->getStatePath()}] field\'s selected options because it did not have an [options()] or [getOptionLabelUsing()] configuration. Please use one of these methods to inform Filament which options are valid for this field."); } + $state = $this->getState(); + + if (blank($state)) { + return null; + } + $optionLabel = $this->getOptionLabel(withDefault: false); if (blank($optionLabel)) { return []; } - $state = $this->getState(); - if ($state instanceof BackedEnum) { $state = $state->value; } diff --git a/packages/tables/src/Columns/SelectColumn.php b/packages/tables/src/Columns/SelectColumn.php index 9874b7eabf..7902293d49 100644 --- a/packages/tables/src/Columns/SelectColumn.php +++ b/packages/tables/src/Columns/SelectColumn.php @@ -67,8 +67,6 @@ class SelectColumn extends Column implements Editable, HasEmbeddedView protected ?Closure $getOptionLabelUsing = null; - protected ?Closure $getOptionLabelsUsing = null; - protected ?Closure $getOptionsSearchResultsUsing = null; protected bool | Closure $shouldSearchOptionLabels = true; @@ -144,6 +142,12 @@ class SelectColumn extends Column implements Editable, HasEmbeddedView */ public function getRules(): array { + $state = $this->getState(); + + if (blank($state)) { + return $this->getBaseRules(); + } + $optionLabel = $this->getOptionLabel(withDefault: false); if (blank($optionLabel)) { @@ -153,8 +157,6 @@ class SelectColumn extends Column implements Editable, HasEmbeddedView ]; } - $state = $this->getState(); - if ($state instanceof BackedEnum) { $state = $state->value; }