Release v21.16.0
Added
CommandFormacceptspopulateFromQuery/populateFromObservableQuery(plus sharedpopulateFromQueryArgs) to seed its initial values from a single-instance query's result, matched onto the command's properties by name.usePopulateFromQuery/usePopulateFromObservableQuery- the underlying hooks, usable directly outsideCommandForm.- Two new field props (available on every field type, since they flow through
asCommandFormField):noInitialValueskips a field entirely;initialValueoverrides how a field's value is derived from the population source - either a property accessor matched by name, or a function composing a value from the whole source. - A query that turns out to return multiple instances throws
QueryReturnsMultipleInstances- a form's initial values only ever come from one instance. - The resolved data becomes the form's baseline through the command's own change tracking, not just a value overlay -
hasChangesreadsfalseright after population, and validation only reruns when the resolved data itself changes. - New "Populating a Form from a Query" documentation section, cross-linked from the existing manual fetch-and-seed pattern.
(#2549)
Notes for reviewers
The issue asks for a single mechanism supporting both regular and observable queries. React's Rules of Hooks make one unified prop that auto-detects regular-vs-observable at runtime genuinely hard, without resorting to a synthetic fallback query class that carries its own risk. This PR exposes two explicit props instead (populateFromQuery / populateFromObservableQuery) - the caller picks whichever matches their query's actual type at the type level, with no runtime branching required.