mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
fix: Do not fetch option labels for blank state (#17930)
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user