Skip to content

Form generator: tristate-aware blank-optional field submit handling #223

Description

@dmealing

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions