Create form vs edit form — the differences
Derive a short create form and a full sectioned edit form from one flat field set, and hand-shape the create form only when its layout truly differs.
Scenario
The form for creating a record should ask only a handful of fields (the essentials). The form for editing an existing record shows the full record, grouped into sections. How do I model this without maintaining two field lists that drift apart?
Recommended solution
Do not author two forms. Author one field set with enough intent that both forms derive from it — then override only when you must.
1. Put the intent on the fields
The create-form subset is not an arbitrary pick; it is derivable from signals that already live on each field:
| Field signal | Effect on the create form |
|---|---|
required: true | must appear on create |
readonly / formula / rollup / autonumber / system-stamped | never on create (you can't set it) |
defaultValue present | can be omitted from create (it self-fills) |
hidden | off everywhere by default |
group | which section the field belongs to (semantic, travels with the model — and only once that group is declared in fieldGroups; see §2) |
| declaration order | the order you write fields in is the default order everywhere — there is no field.order |
So a sensible create form is: editable, required-or-core fields, in declaration order — and it falls out of the object. This is ADR-0047's guardrail: omission is correct — emit nothing extra and you still get a complete, correct form.
2. The default (edit) form derives from field.group — as authorized by fieldGroups
field.group on its own does not create a section. The authorization source is the object's fieldGroups declaration: deriveFieldGroupLayout (ADR-0085 §5) — the single derivation every renderer and the i18n walker consume — sections only those fields whose group matches a declared fieldGroups[].key.
- An undeclared
grouprenders exactly like nogroupat all: the field drops into a trailing untitled bucket. - Declare no
fieldGroupsat all and grouping does not apply — the derivation yields nothing and you get a flat form. - Either way,
os lint(andos build/os validate) reports every unmatched reference asfield-group-undeclared.
So tag the fields and declare the groups — contact.object.ts does both. With both halves present, the full edit form materialises each declared group into a section, and you can omit the form view entirely and let the platform derive the grouped form. Two ways the derived form still differs from the hand-written one below:
- fields the platform injects and you never grouped (
owner_id, undersharingModel: 'private') surface in that trailing untitled section; columnsis a form-view knob, and the group declaration has no column count to give — a derived section carries onlykey/label/icon/description/collapseand its member fields — so a hand-writtencolumns: 2is not part of what derivation gives back.
When you do write the form, list fields as bare strings so each one inherits its type / validation / FLS / default from the object — the form carries layout only, never data semantics.
3. Hand-shape the create form only when layout or flow diverges
The escape hatch is a named form view bound to the create entry point. Author it as a sparse override — mostly a list of field names — not a from-scratch restatement:
import { defineView } from '@objectstack/spec';
const data = { provider: 'object' as const, object: 'showcase_contact' };
export const ContactViews = defineView({
list: {
type: 'grid', data,
columns: [{ field: 'name' }, { field: 'email' }, { field: 'company' }, { field: 'stage' }],
// The "+ Add record" button opens the create form — `formViews.create` below:
addRecord: { enabled: true },
},
// Full edit form — one section per group DECLARED in the object's
// `fieldGroups`; bare strings inherit field defs.
form: {
type: 'simple', data,
sections: [
{ name: 'contact', label: 'Contact', columns: 2, fields: ['name', 'email', 'phone'] },
{ name: 'work', label: 'Work', columns: 2, fields: ['company', 'title'] },
{ name: 'status', label: 'Status', columns: 2, fields: ['stage', 'lead_score'] },
{ name: 'notes', label: 'Notes', columns: 1, fields: ['notes'] },
],
},
formViews: {
// Sparse create override: only the core fields, one section. Omits
// lead_score (readonly), stage (defaulted), notes (edit-time only).
create: {
type: 'simple', data, title: 'New contact',
sections: [
{ name: 'who', label: 'Who is this?', columns: 1, fields: ['name', 'email', 'phone', 'company'] },
],
},
},
});The create form is chosen by convention, and nothing on the list names it: every create entry — the list's Add button (AddRecordConfigSchema says only whether it shows and where) and the object's New — opens formViews.create when the container declares it, else form (or formViews.default). No formViews.create → the create entry uses the default form. Present → it wins for create.
Why
Three layers, each derive + only store differences — never "re-list all 40 fields":
1. Derived default derive(object, 'create' | 'edit') ← free, no authoring
2. Author override formViews.create (sparse patch) ← this recipe; only on real divergence
3. Runtime override environment overlay (ADR-0005) ← an admin edits it in Studio; per-org overlays retired (ADR-0131 D6)Welding two independent full forms is the Salesforce page-layout tax: add a required field, forget the create form → runtime "missing required field" on create; rename a field → silent drift. Keeping data semantics on the object (never on the form) means a form can only ever drift on which fields appear — a flat name list that reference-integrity diagnostics catch as a hard failure in the AI loop (ADR-0047 §3.5, ADR-0033). That guardrail is what makes the escape hatch safe to hand to an AI author.
The create fields are a prefix/subset of the edit fields in the same order and groups, so "quick-create 4 fields → save → land on the full record" stays visually continuous. Derivation preserves that for free; two hand-authored forms break it.
When to actually reach for the override
| Your real need | Use |
|---|---|
| Create asks fewer fields (required + a few core) | Pure derivation — don't hand-write |
| Create groups differently but is just a smaller subset | Usually still derivation (a 5-field form needs no sections) |
| Create is a wizard / multi-step, has create-only copy, conditional reveal, bespoke layout | Hand-write formViews.create |
Rule of thumb: "different field subset" → derive. "different layout or flow" → override. Writing a full create form just to drop a few fields walks straight back into the two-artifact drift trap.
Runnable example
- Object:
examples/app-showcase/src/data/objects/contact.object.ts— flat, intent-tagged field set, with the fourfieldGroupsitsgrouptags point at. - Views:
examples/app-showcase/src/ui/views/contact.view.ts— full edit form + sparseformViews.create+ the list's Add button (addRecord: { enabled: true }), which opens it by convention.
Modal or page: editMode
Where the form opens is a separate choice from what it holds, made on the object:
import { ObjectSchema } from '@objectstack/spec/data';
export const Account = ObjectSchema.create({
name: 'account',
label: 'Account',
sharingModel: 'private',
editMode: 'page', // 'modal' (the Console's default) | 'page'
fields: { name: { type: 'text', label: 'Name', required: true } },
});modalopens Create and Edit in a dialog over the current view: short forms and quick edits.pagegives the form its own route under the active app,/apps/:appName/:objectName/newand/apps/:appName/:objectName/record/:recordId/edit: a URL that can be bookmarked and shared, survives a refresh (the form re-reads the record from the URL) and closes with Back. It suits long, tabbed or wizard forms.
Both render the same form, so sections, validation and visibility rules behave identically.
The change is additive: the existing Create and Edit entry points, the list's per-row Edit
included, follow editMode with no other edit. To open the page routes from a page element,
an action:button names the Console's navigate_create or navigate_edit handler in
properties.actionType, with its arguments in properties.params (a node-level params is
the action's input list and is ignored here). Strings in properties.params are templates,
so a button on a record page names its record with ${record.id}; inside an object view the
active object is already known and params can be omitted.
{
"type": "action:button",
"properties": {
"label": "Edit",
"icon": "pencil",
"actionType": "navigate_edit",
"params": { "objectName": "account", "recordId": "${record.id}" }
}
}Anti-patterns
- Two full hand-authored field lists (
contact_create_form+contact_edit_form). Guaranteed drift; the create form silently misses new required fields. - Restating field type / validation / options on the form. Data semantics live on the object only; the form chooses which fields and where.
- Reaching for
formViews.createto drop fields. That's derivation's job — reserve the override for genuine layout/flow divergence.
See also
- Decision record: ADR-0047 (object UI run modes — derive-default + override).
- Field grouping & order — the three different meanings of "group".
- Reference: View / FormView schema, Field schema.