Skip to content

[5.x] Ensure default config values are available in form tag #10088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 15, 2024
Merged
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
Loading