Skip to content

feat(resource-kit): start a create form on a field's value default - #61

Merged
yyyyaaa merged 1 commit into
mainfrom
feat/resource-kit-value-create-default
Nov 9, 2026
Merged

yyyyaaa merged 1 commit into
mainfrom
feat/resource-kit-value-create-default

Conversation

@yyyyaaa

@yyyyaaa yyyyaaa commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Summary

A create form now opens on a field's database default instead of an empty control.

  • ResourceField.createDefault takes { value } alongside 'now'. A create form starts that field on the value: a priority select defaulting to Medium shows Medium, not None.
  • An explicit form default (defaultValues, such as a related list's parent) still wins, and edit forms still read the stored value.
  • The docs entry for ResourceField.createDefault describes both forms.
priority: {
  name: 'priority',
  label: 'Priority',
  input: 'select',
  options: [{ value: 'Low', label: 'Low' }, { value: 'Medium', label: 'Medium' }],
  createDefault: { value: 'Medium' },
},

Context

Found while dogfooding desktop v0.1.0-beta.4: a generated "New wishlist idea" form showed None for a required priority, and saving it empty stored Medium, so the data was right but the form hid the default. Once this lands in registry-dist, the app template's generator will emit createDefault: { value } from the AppSpec field's default (_meta only says a column has a default, not which), and the desktop will move its registry pin.

🤖 Generated with Claude Code

https://claude.ai/code/session_017WbsG7JQsKEMKNgVsc4psk

ResourceField.createDefault took only 'now', for dates. A field whose column has
a database default, such as a priority select defaulting to Medium, opened as
None, although saving it empty stored Medium. createDefault now also takes
{ value }, which a create form starts on; explicit form defaults and edit forms
keep taking precedence.
@tenki-reviewer

tenki-reviewer Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This PR extends the resource-kit create-default mechanism so fields can declare a default as an object ({ value: <string|number|boolean> }) in addition to the existing static and now sentinel forms. The form-values coercion branch now unwraps .value from object defaults before normal conversion, types.ts widens the createDefault union accordingly, the app-kit docs describe the new shape, and the resource-kit test suite covers numeric object defaults plus the edit-mode rule that stored record values override create defaults.

Reviewed commit: 3ce30b3

@yyyyaaa
yyyyaaa merged commit 99a7955 into main Nov 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant