Overview
The Form component is a powerful, declarative form builder that handles various input types including text fields, document uploads, and CSV processing. It automatically manages file uploads, validation, and submission with built-in error handling.Basic Usage
Element Types
Text Elements
Text elements support various formats and styling options:- Basic Text
- Currency
- Percentage
Document Elements
Handle PDF and ZIP file uploads with automatic processing:CSV Elements
Process CSV files and extract data:API Reference
FormProps
Array of form elements defining the structure and validation rules.
Callback function called when form is successfully submitted.
FormElement Types
BaseFormElement
BaseFormElement
TextElement
TextElement
Text input element with formatting options:
Element type identifier.
Input format for automatic formatting and validation.
Default value for the text field.
Text prefix displayed before the input (e.g., ”$” for currency).
Text postfix displayed after the input (e.g., ”%” for percentage).
DocumentElement
DocumentElement
CSVElement
CSVElement
CSV file upload element:
Element type identifier.
Return Data Types
TheonSubmit callback receives a results object with the following data types:
Text inputs return their string values.
Single document uploads return an object with
id and fileName.Multiple document uploads return an array of document objects.
CSV uploads return an array of objects, one per row, with column headers as keys.
Supported File Types
Document Upload
- PDF Files:
.pdfdocuments for medical records, reports, and forms - ZIP Archives:
.zipfiles containing multiple documents - HTML Files:
.htmlfiles for web-based documents
CSV Upload
- CSV Files:
.csvfiles with tabular data (comma-separated values) - Text CSV: Plain text files with CSV format
Form Features
Text Input Formatting
- Currency: Automatically formats numbers with decimal places and
$prefix - Percentage: Automatically formats numbers with
%postfix - Custom Prefixes/Postfixes: Override default formatting with custom text
File Upload Features
- Drag & Drop: Users can drag files directly onto upload areas
- Multiple Files: Support for uploading multiple documents when
allowMultipleis enabled - File Preview: Shows selected file names with remove buttons
- Upload Progress: Real-time upload status with loading indicators
- Error Handling: Individual file upload error messages with retry capability
Form Validation
- Built on
react-hook-formwithzodschema validation - Real-time validation feedback
- Prevents submission until all uploads complete successfully
- Form-wide error handling with specific error messages
Advanced Examples
Complex Healthcare Form
Form with Conditional Logic
Error Handling
The Form component includes built-in error handling for file uploads and validation:Individual File Errors: Each file upload is handled independently. Failed uploads show specific error messages while successful uploads complete normally.
Upload Behavior
Asynchronous File Processing
The Form handles file uploads asynchronously:- Form Submission: When submitted, all files are uploaded in parallel
- Upload Status: Each file shows individual loading/success/error states
- Completion:
onSubmitis called only after all uploads complete - Error Handling: If any upload fails,
onSubmitreceives an empty object{}
Upload Data Flow
Integration with Workflow System
The Form component integrates seamlessly with the SampleHC workflow system:- Automatic Upload: Documents are uploaded to the platform and return permanent IDs
- Progress Tracking: Built-in loading states and progress indicators
- Error Recovery: Robust error handling with retry mechanisms