getFieldDefaultValue
Generates appropriate default values for different field types in dynamic forms.
Uses registry configuration to determine how each field type should handle values. Supports exclude/flatten/include modes based on field type registration.
Presentation
function getFieldDefaultValue (
field: FieldDef <unknown>,
registry: Map<string, FieldTypeDefinition <any>>,
): unknown;Returns
unknown -Appropriate default value based on field type and configuration
Parameters
| Name | Type | Description |
|---|---|---|
| field | | Field definition to generate default value for |
| registry | Map<string, | Field type registry for value handling configuration |
Example usage
// Basic input field defaults to empty string
getFieldDefaultValue ({ type: 'input', key: 'email' }, registry); // ''
// Excluded fields (like text/row) return undefined
getFieldDefaultValue ({ type: 'text', key: 'label' }, registry); // undefined
// Group field returns object with child defaults
getFieldDefaultValue ({
type: 'group',
key: 'address',
fields: [
{ type: 'input', key: 'street' },
{ type: 'input', key: 'city', value: 'New York' }
]
}, registry); // { street: '', city: 'New York' }