diff --git a/src/Fields/Field.php b/src/Fields/Field.php index 9bf06782..18ce8f0a 100644 --- a/src/Fields/Field.php +++ b/src/Fields/Field.php @@ -88,6 +88,11 @@ abstract class Field implements Arrayable, JsonSerializable */ protected ?string $apiUri = null; + /** + * Indicates if the field has been hydrated. + */ + protected bool $hydrated = false; + /** * Create a new field instance. */ @@ -274,9 +279,11 @@ public function suffix(string $value): static */ public function resolveValue(Request $request, Model $model): mixed { - $value = $this->withOldValue && $request->session()->hasOldInput($this->getRequestKey()) - ? $this->getOldValue($request) - : $this->getValue($model); + if (! $this->hydrated && $this->withOldValue && $request->session()->hasOldInput($this->getRequestKey())) { + $this->resolveHydrate($request, $model, $this->getOldValue($request)); + } + + $value = $this->getValue($model); if (is_null($this->valueResolver)) { return $value; @@ -351,6 +358,8 @@ public function resolveHydrate(Request $request, Model $model, mixed $value): vo } call_user_func_array($this->hydrateResolver, [$request, $model, $value]); + + $this->hydrated = true; } /**