Skip to content

Commit

Permalink
[5.x] Ensure default config values are available in form tag (#10088)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Varga <jason@pixelfear.com>
  • Loading branch information
duncanmcclean and jasonvarga authored May 15, 2024
1 parent 024aad4 commit ea6ec7d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Tags/Concerns/RendersForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Closure;
use Illuminate\Support\MessageBag;
use Statamic\Fields\Field;
use Statamic\Support\Str;

trait RendersForms
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit ea6ec7d

Please sign in to comment.