Default Choices in a Web Form
A form can prefill a conventional value while leaving a user's explicit changes and the backend rule distinguishable.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace omitted and empty choices
A window length can default to seven days for a new form. If an edit explicitly clears the optional length, the application should retain that intent according to its contract. Default argument policy describes a similar omission rule.
Keep display and saved state aligned
After an error, use supplied values rather than autofilling over a deliberate choice. Ensure the accompanying label states the unit. See protecting drafts.[1][2]
Check the difference between an initial suggestion and validation
A create form can initially suggest medium priority. If a user selects low and another field fails, rerender the submitted low choice so the correction does not reset it. The displayed default does not permit arbitrary submitted values. See default arguments and domain policy.
Initial form: medium selected
Submit low with incomplete title
Redisplay low plus title error
Reject an unsupported priority explicitly
Handle absence in update forms according to the operation
An omitted value can mean preserve existing state or require a new selection. Test creation and editing separately. A persisted option removed from current choices may need a deliberate display and validation rule.