Field Types
Schema FormX defines 5 basic field types that are used to determine the type of form control and the type of bound data.
Field Type List
Default Values
When form initializes, default values are automatically set based on field type:
Override defaults using defaultData:
Empty Value Rules
The following values are considered empty and will trigger required validation:
Note: The default error message is currently hardcoded in Chinese (
${label}不能为空). To display English error messages, use a customvalidatorfunction to override the default required validation.
Important Notes:
falseforbooleantype is NOT empty - required validation passes0fornumbertype is NOT empty - required validation passes- Empty string
''is considered empty for all types
Data Type Conversion: Schema FormX does not perform automatic type conversion. If a field is declared as
type: 'number', the bound data will be whatever value the component'sonChangeemits (e.g., if the component emits a string"123", the data value will be"123", not123). It is the component's responsibility to emit values of the correct type.
String Type
The string type is the most commonly used field type, suitable for text input.
Basic Usage
Common Props
Examples
Default Component: Input
Common Scenarios:
- Username, email, phone number
- Address, description
- Password, verification code
Number Type
The number type is used for numeric input, supporting integers and floating-point numbers.
Basic Usage
Common Props
Note: The following props are commonly used props of the DefaultControl (default InputNumber component), passed via
schema.props.
Examples
Default Component: InputNumber
Common Scenarios:
- Age, quantity
- Price, amount
- Score, percentage
Boolean Type
The boolean type is used for boolean values, usually corresponding to checkboxes or switches.
Basic Usage
Common Props
Note: The following props are commonly used props of the DefaultControl (default Checkbox/Switch component), passed via
schema.props.
Examples
Default Component: Checkbox
Common Scenarios:
- Agreement confirmation
- Enable/disable option
- Yes/no selection
Object Type
The object type is used for complex data structures that need to be managed as a whole. It requires a custom component.
Basic Usage
Default Component: Custom component required
Common Scenarios:
- Address selection (Province/City/District)
- Coordinate selection (Longitude/Latitude)
- Structured input for complex objects
Default Value: Object type defaults to {}, empty object {} is considered empty in required validation.
Array Type
The array type is used for list data that needs to be managed as a set. It requires a custom component.
Basic Usage
Default Component: Custom component required
Common Scenarios:
- Tag input
- File upload list
- Multiple selections
Default Value: Array type defaults to [], empty array [] is considered empty in required validation.
Field Type Examples
Input Component
Type Selection Guide
When to use String type:
- Text input
- Single-line or multi-line text
- Dropdown selection
- Date selection
When to use Number type:
- Numeric values
- Quantities, amounts
- Scores, percentages
When to use Boolean type:
- Yes/no choices
- Enable/disable switches
When to use Object type:
- Nested structures
- Multi-field organized data
- Address, contact information
When to use Array type:
- Multiple values
- Dynamic list
- Tag input
Related Documentation
- Form Configuration - Learn about schema structure
- Custom Components - Learn how to customize components