Forms
Build data entry forms with validation and data binding
Forms Guide
Learn how to create powerful forms in Appivo using widgets, data binding, and validation.
Form Building Overview
Appivo forms are built by combining:
| Component | Purpose |
|---|---|
| Input Widgets | Capture user data |
| Container Widgets | Organize layout |
| Data Binding | Connect to models |
| Validation | Ensure data quality |
| Actions | Process submissions |
Creating a Form
Step 1: Design the Layout
- Navigate to User Interfaces
- Create or edit a view
- Add container widgets for structure
- Organize into logical sections
Step 2: Add Input Widgets
Drag input widgets to capture data:
| Widget | Purpose | Common Uses |
|---|---|---|
| TextField | Single-line text | Names, titles |
| TextArea | Multi-line text | Descriptions, notes |
| NumberField | Numeric input | Quantities, prices |
| EmailField | Email addresses | Contact info |
| PhoneField | Phone numbers | Contact info |
| DateField | Date selection | Birthdays, deadlines |
| TimeField | Time selection | Appointments |
| Select | Dropdown choice | Categories, status |
| RadioGroup | Single choice | Options, preferences |
| CheckBox | Boolean toggle | Agreements, flags |
| FileUpload | File attachment | Documents, images |
Step 3: Bind to Data
Connect widgets to model attributes:
Widget: TextField
Property: value
Binding: customer.name
When the user types, the model attribute updates automatically.
Step 4: Add Validation
Configure validation on each widget:
Widget: TextField (Email)
Validations:
- Required: true
- Pattern: valid email format
- Error Message: "Please enter a valid email"
Step 5: Add Submit Button
Add a Button widget to submit the form:
Widget: Button
Label: "Save"
onClick: Save record and navigate to list
Form Layout Patterns
Simple Form
Single-column layout for straightforward data entry:
Panel: Contact Form
├── TextField: First Name
├── TextField: Last Name
├── EmailField: Email
├── PhoneField: Phone
└── Button: Save
Sectioned Form
Organize related fields into sections:
Panel: Personal Information
├── TextField: First Name
├── TextField: Last Name
└── DateField: Birth Date
Panel: Contact Details
├── EmailField: Email
├── PhoneField: Phone
└── TextField: Address
Panel: Preferences
├── Select: Language
├── CheckBox: Newsletter
└── RadioGroup: Contact Method
Panel: Actions
├── Button: Save
└── Button: Cancel
Two-Column Layout
Use FlexContainer or GridContainer:
GridContainer (2 columns)
├── TextField: First Name
├── TextField: Last Name
├── EmailField: Email
├── PhoneField: Phone
├── TextField: City (span 2 columns)
Data Binding
Binding Input Values
Connect widget values to model attributes:
| Widget | Binding Property | Example |
|---|---|---|
| TextField | value | customer.name |
| NumberField | value | order.quantity |
| Select | selectedValue | order.status |
| CheckBox | checked | customer.active |
| DateField | value | order.due_date |
Binding to Related Data
Populate dropdowns from related models:
Widget: Select (Category)
Options Source: Category model
Display Field: name
Value Field: id
Binding: product.category_id
Calculated Fields
Display computed values:
Widget: Label (Total)
Value: order.quantity * order.unit_price
Read-only: true
Validation
Widget-Level Validation
Configure validation on each input widget:
| Property | Description |
|---|---|
| required | Field is mandatory |
| minLength | Minimum characters |
| maxLength | Maximum characters |
| min | Minimum number value |
| max | Maximum number value |
| pattern | Regex pattern |
| errorMessage | Custom error text |
Validation Timing
| Setting | When Validated |
|---|---|
| On Blur | When field loses focus |
| On Change | On every keystroke |
| On Submit | When form is submitted |
Cross-Field Validation
Validate one field against another:
Attribute: confirm_password
Validation:
- Must equal: password
- Error: "Passwords must match"
Validation Feedback
Configure how errors display:
- Red border on invalid fields
- Error message below field
- Error summary at form top
- Disable submit until valid
Form Submission
Button Actions
Configure what happens when the form submits:
Button: Save
onClick:
1. Validate all fields
2. Save record to model
3. Show success message
4. Navigate to list view
Using Rules and Actions
For complex form processing, create a Rule:
Rule: Process Order Form
Type: DATA
Trigger: When Order is created
Action 1: SCRIPT
- Calculate totals
- Apply discounts
- Validate inventory
Action 2: SENDMAIL
- Send confirmation to customer
Action 3: WEBHOOK
- Notify fulfillment system
Success Handling
After successful submission:
- Show success message or toast
- Navigate to another view
- Reset the form
- Display created record
Error Handling
When submission fails:
- Show clear error message
- Highlight problem fields
- Preserve entered data
- Allow correction and retry
Advanced Form Patterns
Conditional Fields
Show fields based on other values:
Select: Customer Type
Options: Personal, Business
TextField: Company Name
Visible when: customerType = "Business"
TextField: Tax ID
Visible when: customerType = "Business"
Dynamic Options
Load dropdown options based on selection:
Select: Country
Options: [List of countries]
Select: State/Province
Options: Loaded based on selected country
Dependency: Country selection
Multi-Step Forms
Break long forms into steps using TabContainer:
TabContainer: Registration Wizard
├── Tab 1: Account Information
│ ├── EmailField: Email
│ └── PasswordField: Password
├── Tab 2: Personal Details
│ ├── TextField: Name
│ └── DateField: Birth Date
├── Tab 3: Preferences
│ └── CheckBox: Terms
└── Tab 4: Confirmation
└── Review summary
Inline Editing
Edit records directly in a DataGrid:
DataGrid: Products
Columns:
- name (editable)
- price (editable)
- stock (editable)
Edit Mode: inline
Save: On blur or Enter key
Form Best Practices
Layout
- Group related fields together
- Order fields logically
- Use clear section headings
- Keep forms as short as possible
- Use appropriate input types
Labels and Help
- Use clear, descriptive labels
- Add placeholder text for hints
- Provide help text for complex fields
- Mark required fields clearly
- Show format expectations
Validation
- Validate early when possible
- Show specific error messages
- Don't block valid input
- Preserve entered data on errors
- Summarize all errors clearly
Submission
- Disable submit during processing
- Show loading indicator
- Give clear success feedback
- Handle errors gracefully
- Confirm destructive actions
Accessibility
- Use proper labels (not just placeholders)
- Ensure keyboard navigation works
- Maintain logical tab order
- Provide error announcements
- Support screen readers
Mobile Forms
For mobile interfaces, use M-prefixed widgets:
| Desktop Widget | Mobile Widget |
|---|---|
| TextField | MTextField |
| TextArea | MTextArea |
| Select | MSelect |
| DateField | MDateField |
| Button | MButton |
Mobile form considerations:
- Stack fields vertically
- Use full-width inputs
- Provide adequate touch targets (44px minimum)
- Use native date/time pickers
- Consider keyboard type for each field
Next Steps
- Validation Guide - Detailed validation patterns
- User Interfaces - Complete UI building guide
- Rules and Actions - Process form submissions