Skip to content

Commit 63220d6

Browse files
committed
add default value to fields
1 parent 6e47a2b commit 63220d6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Fields/Base.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public function getForm(): array
4848
return ! empty(trim($hint));
4949
}),
5050
]),
51+
Forms\Components\TextInput::make('config.defaultValue')
52+
->label(__('Default value'))
53+
->helperText(__('This value will be used when creating new records.')),
5154
];
5255
}
5356

@@ -61,6 +64,7 @@ public static function getDefaultConfig(): array
6164
'hint' => null,
6265
'hintColor' => null,
6366
'hintIcon' => null,
67+
'defaultValue' => null,
6468
];
6569
}
6670

@@ -78,6 +82,10 @@ public static function applyDefaultSettings($input, ?Field $field = null)
7882
$input->hintColor(Color::hex($field->config['hintColor']));
7983
}
8084

85+
if (isset($field->config['defaultValue']) && $field->config['defaultValue'] !== null) {
86+
$input->default($field->config['defaultValue']);
87+
}
88+
8189
return $input;
8290
}
8391

0 commit comments

Comments
 (0)