Forms and Data Input
Standardize validation, errors, and complex form composition.
Key takeaways
- Reliable agent-generated forms require a standardized field contract for labels, help text, errors, required state, validation, and submission.
- Validation should run on a shared schema rather than one-off string checks, and errors must be specific, actionable, and programmatically linked.
- Agents must use form primitives, connect errors with
aria-describedby, and never hide required constraints until after submission. - Preserve user input on failed submission and cover empty, loading, success, and error states for complex forms.
- Multi-step and conditional forms need a documented step model, defined back/next behavior, partial-data preservation, and network-failure recovery.
Forms are the core interface between users and systems. Agents can generate reliable forms only when field composition, validation, error handling, and submission states are standardized.
Field Contract
| Field part | Requirement |
|---|---|
| Label | Visible unless there is a specific approved exception. |
| Help text | Explains constraints before failure. |
| Error | Specific, actionable, and programmatically linked. |
| Required state | Clear and consistent. |
| Validation | Shared schema, not one-off string checks. |
| Submission | Loading, success, failure, and retry states. |
Standard Pattern
<FormField name="email">
<FormLabel>Email</FormLabel>
<TextInput type="email" autoComplete="email" />
<FormDescription>Use your work email.</FormDescription>
<FormError />
</FormField>Agent Rules
- Use the form primitives before custom field markup.
- Connect errors with
aria-describedby. - Do not hide required constraints until after submission.
- Preserve user input on failed submission.
- Include empty, loading, success, and error states for complex forms.
Complex Forms
For multi-step or conditional forms:
- document the step model;
- show validation timing;
- define back/next behavior;
- preserve partial data;
- provide recovery for network failures.
Verification
- Schema validation tests.
- Accessibility checks for labels and errors.
- Keyboard traversal.
- Mobile layout screenshots.
- Submission failure simulation.