mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
fix: Select label update when not preloaded
This commit is contained in:
+1
-1
File diff suppressed because one or more lines are too long
@@ -146,7 +146,7 @@ export default function selectFormComponent({
|
||||
}
|
||||
|
||||
await this.refreshChoices({
|
||||
withInitialOptions: !hasDynamicOptions,
|
||||
withInitialOptions: false,
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
@@ -433,10 +433,8 @@ class Select extends Field implements Contracts\CanDisableOptions, Contracts\Has
|
||||
})
|
||||
->fillForm($this->getEditOptionActionFormData())
|
||||
->action(static function (Action $action, array $arguments, Select $component, array $data, ComponentContainer $form) {
|
||||
$statePath = $component->getStatePath();
|
||||
|
||||
if (! $component->getUpdateOptionUsing()) {
|
||||
throw new Exception("Select field [{$statePath}] must have a [updateOptionUsing()] closure set.");
|
||||
throw new Exception("Select field [{$component->getStatePath()}] must have a [updateOptionUsing()] closure set.");
|
||||
}
|
||||
|
||||
$component->evaluate($component->getUpdateOptionUsing(), [
|
||||
@@ -444,9 +442,7 @@ class Select extends Field implements Contracts\CanDisableOptions, Contracts\Has
|
||||
'form' => $form,
|
||||
]);
|
||||
|
||||
/** @var LivewireComponent $livewire */
|
||||
$livewire = $component->getLivewire();
|
||||
$livewire->dispatch('filament-forms::select.refreshSelectedOptionLabel', livewireId: $livewire->getId(), statePath: $statePath);
|
||||
$component->refreshSelectedOptionLabel();
|
||||
})
|
||||
->color('gray')
|
||||
->icon(FilamentIcon::resolve('forms::components.select.actions.edit-option') ?? 'heroicon-m-pencil-square')
|
||||
@@ -1226,4 +1222,16 @@ class Select extends Field implements Contracts\CanDisableOptions, Contracts\Has
|
||||
|
||||
return $relationship->getQualifiedOwnerKeyName();
|
||||
}
|
||||
|
||||
public function refreshSelectedOptionLabel(): void
|
||||
{
|
||||
/** @var LivewireComponent $livewire */
|
||||
$livewire = $this->getLivewire();
|
||||
|
||||
$livewire->dispatch(
|
||||
'filament-forms::select.refreshSelectedOptionLabel',
|
||||
livewireId: $livewire->getId(),
|
||||
statePath: $this->getStatePath(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user