Complex form scenarios with multi-step wizards, dynamic fields, conditional validation, and more.
circle-check
What you'll learn...
Multi-step wizard forms with progress tracking
Dynamic forms (add/remove fields at runtime)
Conditional validation based on field dependencies
Form state management (dirty, pristine, touched)
Autosave and draft management
Complex file uploads with preview and progress
Form arrays (repeating field groups)
All examples assume you have the validation plugin installed and configured:
Copy npm install @aurelia/validation @aurelia/validation-html
Copy // src/main.ts
import Aurelia from ' aurelia ' ;
import { ValidationHtmlConfiguration } from ' @aurelia/validation-html ' ;
Aurelia . register ( ValidationHtmlConfiguration )
. app ( component )
. start () ; See Validation documentation for setup details.
Multi-step forms break complex forms into manageable steps, improving user experience and completion rates.
Complete Example: User Onboarding Wizard
Key Features :
Step-by-step validation (only validate current step)
Conditional validation rules with .when()
Navigate to first step with errors on final submit
Accessible navigation buttons
Forms where users can add or remove fields at runtime, like adding multiple email addresses or phone numbers.
Key Features :
Add/remove email entries dynamically
Ensure at least one email exists
Automatically handle primary email when removing
Validate all emails in the array
Unique IDs for each entry (accessibility and key binding)
Conditional Validation (Field Dependencies)
Validation rules that change based on the values of other fields.
Key Features :
Conditional field visibility with if.bind
Conditional validation with .when()
Fields depend on checkbox state
Fields depend on select values
Automatic revalidation when dependencies change
Track whether forms have been modified and warn users before losing changes.
Complete Example: Article Editor with Unsaved Changes Warning
Key Features :
Dirty state tracking (compare current vs original)
Autosave to localStorage every 30 seconds
Last saved timestamp with human-readable formatting
Prevent navigation with canUnload router hook
Visual indicators for save state
Disable actions while saving
Form arrays allow users to add/remove entire groups of fields, like invoice line items or multiple addresses.
Key Features :
Add/remove line items dynamically
Auto-calculate line totals and invoice totals
Validate entire array of items
Prevent removing last item
Unique IDs for each line item
Accessible labels for screen readers
Complex File Uploads with Preview & Progress
Handle multiple file uploads with image previews, progress tracking, and validation.
Complete Example: Image Gallery Upload
Key Features :
Progress tracking for each file
File type and size validation
Individual or bulk upload
Dependent Dropdowns (Cascading Selects)
Dropdowns where options depend on previous selections, like country → state → city.
Complete Example: Location Selector
Key Features :
Cascading selects (country → state → city)
Computed properties for filtered options
Auto-reset dependent fields when parent changes
Loading states while fetching options
Disabled state until parent is selected
Create reusable form field components that encapsulate label, input, validation, and error display.
Complete Example: Validated Text Field Component
Key Features :
Encapsulates label, input, validation, error display
Reusable across entire application
Consistent styling and behavior
Accessible (proper ARIA attributes)
Reduced boilerplate in forms
These advanced patterns handle complex real-world scenarios:
Multi-step wizards - Break complex forms into manageable steps with conditional validation and progress tracking
Dynamic forms - Add/remove individual fields at runtime with validation
Conditional validation - Validation rules that depend on other field values
Form state management - Track changes, prevent data loss, implement autosave with router guards
Form arrays - Repeating field groups (like invoice line items) with add/remove/duplicate functionality
Complex file uploads - Multiple file uploads with drag & drop, previews, progress tracking, and per-file validation
Dependent dropdowns - Cascading selects (country → state → city) with auto-reset and loading states
Reusable form fields - Encapsulated field components with built-in validation display
All examples use proper Aurelia 2 syntax with the validation plugin and follow accessibility best practices. Each pattern includes complete, production-ready code with TypeScript interfaces, validation rules, and accessible HTML templates.
Last updated 4 months ago