Values, snapshots, and submission
Initial state and restoration
Use initialValues for an ordinary record seed. overrideValues take precedence and suit values your application controls. For complete restoration, prefer initialSnapshot:
Code
The snapshot keeps raw values, nested repeatable section rows, and timestamps together:
Code
onSnapshotChange(snapshot, meta) first reports { kind: "seed", dirty: false }; later user
changes use { kind: "change", dirty }.
Save failures and console messages
When a save fails, FormRenderer keeps the user's values so they can retry, and prints one
console.error report with the failure stage and the original error. It does not show a message to
the user, so do that in your application and then rethrow the error:
Code
If you catch the error without rethrowing it, FormRenderer treats the save as successful.
submissionDiagnostics controls these console messages:
Code
saveFailuresis on by default. Set it tofalseif your application already reports failures.validationBlocksis off by default. Set it totrueto log one line each time validation blocks Submit or a repeatable row's Save.
A required field left empty is a validation block, not a save failure.
Try it
- Tap Submit with a required field empty. The field shows its validation message, and the console stays quiet.
- Add
validationBlocks: trueand tap Submit again. The console shows[form0-react-native] Submit blocked by validation. - Fill in the field, make
saveRecordthrownew Error("Example save failure"), and tap Submit. The console shows[form0-react-native] Submit failed during onSubmit.with your error, and your values stay in the form. - Remove the
throwand tap Submit again. The save succeeds.
Details
- These settings take effect immediately, even while a save is pending. They are separate from
debug,engineOptions.diagnostics.console, and lifecycle settings. - Reports do not include form values, snapshots, or record paths. Preparation failures include their issue codes and messages.
- Cancelling a confirmation stays quiet. An exception thrown by your callback is reported as a callback failure.
form0-coreprints its own lines, such as[EVENT HANDLER] Registered. These settings do not control them.- These settings cover the renderer's built-in actions. If you call
prepareSave()directly, inspect the result it returns. - The same settings apply to draft
onSavefailures. Invalid drafts stay saveable, and a successful draft save logs no validation block.
Save drafts or submit records
Set primaryActionMode="save" and provide onSave(snapshot, meta) for a validation-tolerant draft
action. meta contains the current validation summary and dirty state.
The default submit action validates first. onSubmit(record, meta) receives the structured record
described in Output and records, plus raw values, repeatable state,
timestamps, and the validation summary.
The binding does not persist or synchronize either payload. Store snapshots locally, upload records, retry failures, and resolve conflicts in your application.
Use events from your own code
engineOptions.events sets which events run, and engineOptions.onEventController gives you a
controller for your own buttons. FormRenderer describes both
in full.
| Option | Default | Purpose |
|---|---|---|
events.recordKind | Required | "new" / "existing". |
events.lifecycle | true | Set to false to keep only load-record, edit-record, and change. |
events.fieldInteractions | ["focus", "blur", "click"] | Set to [] to turn off automatic interactions. |
onEventController(controller | null) gives you dispatch(request) and prepareSave(request).
prepareSave() never saves or closes anything. The returned summary lists validation messages for a
main-record draft. Validation failures block a normal submit and row acceptance, and calculation
diagnostics block nothing.
Review recalculated rows
When a user submits, FormRenderer recalculates saved rows automatically. Set
form.repeatable_recalculation to "confirm" in the schema when users should review changed values
first.
submissionOptions changes this from your code:
mode: "confirm"requires a review even if the schema does not."automatic"cannot turn off a confirmation set in the schema.allowRetain: truelets the user keep older values. It does not turn on a review by itself.messagesreplaces the review and status text.
The default review shows row titles and paths, field labels, old and new values, and counts, in pages. A choice applies to all changed rows or none. A save is rejected while a row editor is still open.
All validation findings stay available with their record paths, and the form pages them and links to
the record or field. An INVALID() message belongs to its record, not to a field.
Save the record and its freshness
Code
When your callback completes, form0 treats the save as successful. Save the record and
meta.freshness together before it resolves, and throw or reject on failure or cancellation.
freshness stays outside the form values. Pass the saved one back as initialFreshness. An older
acknowledgement cannot clear newer pending state. If a user keeps older row totals [110,220], the
submitted sum is 330, never the 360 of the refreshed proposal. If the user changes a value from
20 to 24, 24 stays as unsaved work even if validation or saving then fails.
Run a review from your own interface
A controller prepares a save without opening a dialog or saving anything:
Code
Check eligible, handle requires_decision, where payload is null, and acknowledge only the
preparationId you saved. getSaveChanges() returns 50 entries by default and at most 100. To
continue a review, call prepareSave() with
decision: { reviewId, action: "refresh" | "retain" | "cancel" }. Changing the inputs or
configuration, or starting a newer preparation, ends the review.
Validation runs before the save handler, which runs once for each attempt. If the handler changes values, a new review may be needed, but the handler does not run again.
prepareSave({ intent: "draft" }) and the draft save action keep the saved rows' calculated values
without a dialog. Validation failures are reported and still allow a main-record draft, but a
handler failure prevents it. In onSave, save the record and freshness together too. A successful
offline write is separate from later server synchronization.
Setters follow the value rules. initialValues and overrideValues
are more tolerant, including in read-only mode, where calculated values stay as supplied.
Hidden values
A field with
visible_preserve_value: false
is cleared while the user edits, including in closed rows. It stays cleared in raw_values,
repeatable, and the submitted record. Other fields keep their values when hidden, and a read-only
form clears nothing.
To check kept hidden values on final submission, set validateHiddenValues:
Code
A hidden value that fails its own rules then blocks Submit. The user can fix it by making the field visible again, or your application can resolve it. Also check hidden values on your server. Drafts and empty hidden required fields are not affected.
Resolve a hidden value that fails validation
With validateHiddenValues on, a hidden value that fails its own rules blocks Submit, and the
user can't reach the field to fix it. The Issues tab of the navigation sheet explains this. To
let your application fix the value, pass onResolveHiddenValue. The user can then press the
finding, which ends with Resolve hidden value, to run your handler.
Code
Your handler receives fieldName, fieldKey, instancePath, message, and a copy of the current
value. It can return:
{ value: replacement }to replace the value, which must pass the field's own rules{ value: null }to clear itundefinedornullto cancel
The field stays hidden, no change or lifecycle handlers run, and nothing is saved until the user
presses Submit. If the record changes while your handler runs, the reply is discarded and the
user has to submit again. Close any open row first. In a read-only form, the user can't press the
finding.
If clearing the value leaves a row with no answers, the row stays in the record. See Saved empty rows.