You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Form generator: tristate-aware blank-optional field submit handling #223
Deferred from the form-controls view-dispatch cycle (spec: docs/superpowers/specs/2026-07-18-form-controls-view-dispatch-design.md).
A generated form's blank optional scalar inputs submit "" (empty string). For a nullable date/timestamp column this is invalid, and a != null check misreads "" as "set". A downstream implementation worked around this by deleting ""-valued keys from the submit payload. That fix was not promoted because it conflicts with FR-035 present-key PATCH tristate: deleting a cleared field's key means "untouched", so on the edit/PATCH path clearing a previously-set optional field silently fails to clear it.
The correct behavior is tristate-aware and needs create-vs-edit + dirty-state awareness:
blank on CREATE → omit the key (or send null) so the column defaults/NULLs,
a field that was set and is now cleared on EDIT → send explicit null (present-null clears),
a @required field left untouched → unchanged.
Scope: the generated form's submit handler in codegen-ts-react (and its React runtime binding). Until this lands, the promoted form template inherits the pre-existing ""-vs-NULL wart for blank optional date/timestamp inputs on CREATE.
Implemented as the tristate you specified, keyed on defaultValues (what already
distinguishes the modes since #227):
CREATE — the blank key is OMITTED, so the column's DEFAULT/NULL applies.
EDIT — it is sent as explicit null, which CLEARS the column.
So the FR-035 conflict is avoided rather than traded: deleting the key on the edit path is
exactly what loses the clear.
Scope is decided at codegen time. @required is excluded (blank there is a validation
error the schema owns, and rewriting it would turn a caught error into a silent null), as
are controls that cannot produce "" — checkbox, view.image, nested field.object and
array fields. An entity with no blankable optional field emits no normalizer, so its output
stays byte-identical.
The tests EXECUTE the emitted normalizer rather than grepping for it.
Activity
fix(codegen-ts-react): validate edits against UpdateSchema, not Inser…
fix(codegen-ts-react): a blank optional form field is tristate-aware,…
docs(changelog): record the #223 blank-optional tristate fix
fix(codegen-ts-react): the blank-optional list names only fields with…
dmealing commentedon Aug 23, 2026
Fixed on
mainin af6bd30 + 5e0b13f, shipping in0.24.1.Implemented as the tristate you specified, keyed on
defaultValues(what alreadydistinguishes the modes since #227):
DEFAULT/NULL applies.null, which CLEARS the column.So the FR-035 conflict is avoided rather than traded: deleting the key on the edit path is
exactly what loses the clear.
Scope is decided at codegen time.
@requiredis excluded (blank there is a validationerror the schema owns, and rewriting it would turn a caught error into a silent null), as
are controls that cannot produce
""— checkbox,view.image, nestedfield.objectandarray fields. An entity with no blankable optional field emits no normalizer, so its output
stays byte-identical.
The tests EXECUTE the emitted normalizer rather than grepping for it.