Understanding Custom Properties
Custom properties are key-value pairs that are included in the form and field metadata sent to the client. They allow you to:- Add application-specific configuration to forms and fields
- Pass styling or display hints to the client
- Include additional validation rules
- Store arbitrary metadata for client-side processing
Adding Custom Properties to Fields
UIMetadataFramework.Core provides built-in attributes for common property types.String Properties
UseStringPropertyAttribute to add string values:
Integer Properties
UseIntPropertyAttribute to add integer values:
Boolean Properties
UseBooleanPropertyAttribute to add boolean values:
Adding Multiple Properties
You can add multiple custom properties to a single field:Creating Custom Property Attributes
For complex custom properties, create your own attribute by inheriting fromCustomPropertyAttribute:
Custom Properties on Forms
Add custom properties to entire forms by creating a customFormAttribute:
Array Properties
Some custom properties contain arrays of values. Mark them with[CustomPropertyConfig(IsArray = true)]:
Practical Examples
Example 1: Styling Properties
Example 2: Validation Hints
Example 3: Complex Custom Property
Example 4: Conditional Display
Accessing Custom Properties on the Client
Custom properties are included in the field metadata sent to the client:Complete Example
Here’s a complete example showing various custom properties:Best Practices
- Use Descriptive Names - Choose clear, descriptive names for custom properties
- Document Properties - Document what each custom property does and how it should be used
- Keep It Simple - Don’t overuse custom properties; use them when standard properties aren’t sufficient
- Validate Client-Side - Ensure your client-side code handles missing or invalid custom properties gracefully
- Version Your Properties - If you change custom property structure, consider versioning to maintain backward compatibility
- Type Safety - Use strongly-typed custom attributes rather than string-based properties when possible
Next Steps
Creating Forms
Review form creation basics
Input Components
Learn about input field types