From ea6ec7dc2ae63e3eeb9c885d7f9d5886e5bba9b7 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Wed, 15 May 2024 19:19:02 +0100 Subject: [PATCH] [5.x] Ensure default config values are available in form tag (#10088) Co-authored-by: Jason Varga --- src/Tags/Concerns/RendersForms.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Tags/Concerns/RendersForms.php b/src/Tags/Concerns/RendersForms.php index f80ba5c479..cedf943d6f 100644 --- a/src/Tags/Concerns/RendersForms.php +++ b/src/Tags/Concerns/RendersForms.php @@ -4,6 +4,7 @@ use Closure; use Illuminate\Support\MessageBag; +use Statamic\Fields\Field; use Statamic\Support\Str; trait RendersForms @@ -135,7 +136,12 @@ protected function getRenderableField($field, $errorBag = 'default', $manipulate $default = $field->value() ?? $field->defaultValue(); $value = $old === $missing ? $default : $old; - $data = array_merge($field->toArray(), [ + $configDefaults = Field::commonFieldOptions()->all() + ->merge($field->fieldtype()->configFields()->all()) + ->map->get('default') + ->filter()->all(); + + $data = array_merge($configDefaults, $field->toArray(), [ 'instructions' => $field->instructions(), 'error' => $errors->first($field->handle()) ?: null, 'default' => $field->value() ?? $field->defaultValue(),