Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

plugin-form README 的「Integration with Data Sources」示例把 dataSource / resource 写在 form schema 上 —— 两个键全仓零读取点 #5098

Closed

Description

@yinlianghui

发现于 #5075 的实施(那一单只改 Schema API + Examples 三组键面,本节是另一节、另一类缺陷,故未夹带进 PR)。Filed unassigned, not claiming.

现象

packages/plugin-form/README.md 的 ## Integration with Data Sources 一节教这么接后端:

const schema = {
  type: 'form',
  dataSource,
  resource: 'users',
  fields: [/* fields */],
  onSubmit: async (data) => { await dataSource.create('users', data); }
};

两个键都不成立:

  1. resource —— packages/types/src 里零声明(grep -nE "^\s*resource\??:" packages/types/src/form.ts packages/types/src/objectql.ts 零命中),packages/components/src 与 packages/plugin-form/src 里零读取点。对象名在 object-form 路线上是必填的 objectName;基础 form 根本不按名取数。

  2. dataSource —— 基础 form 渲染器不从 schema 读它:它读的是上下文,packages/components/src/renderers/form/form.tsx:1004 的 const contextDataSource = schemaCtx?.dataSource ?? null,再逐字段下发(:2061);schema/props 上同名键反而是被剥掉的(form.tsx:304、:2168 的 dataSource: _dataSource 丢弃式解构)。

两个键都因 FormSchema extends BaseSchema 的 [key: string]: any(packages/types/src/base.ts:318)而编译通过,也因此永远不报错 —— 照抄这段的读者拿到一个不连后端的表单,只有手写的 onSubmit 闭包在工作(它能跑,但那是闭包捕获的 adapter 在跑,与 schema 无关)。

同一 README 已经写对过

本文件 ### Registering a component under your own key 一节(约 :136-142)已经说明:「SchemaRenderer hands a registered component its schema (plus the schema's own props), but never a dataSource — that travels on SchemaRendererContext」。所以这是同文件的自相矛盾,不是缺失知识。

建议的改法(不新增能力)

按真机制重写该节:adapter 经 SchemaRendererProvider / SchemaRendererContext 注入(AGENTS.md #1),元数据侧用 object-form 的 objectName + mode 走真实读写路径,并像 #5075 落地的其余示例那样给示例加真类型标注(不带标注的 const schema = { … } 写什么都能过编译)。⛔ 不要为了让示例成立而给 FormSchema 新增 resource 或 dataSource 键。

复核方式

sed -n '629,650p' packages/plugin-form/README.md
grep -rnE "^\s*resource\??:" packages/types/src/form.ts packages/types/src/objectql.ts   # 零命中
grep -rn "schema.resource" packages/components/src packages/plugin-form/src              # 零命中
sed -n '1000,1006p;2060,2062p' packages/components/src/renderers/form/form.tsx           # 真读点在 context

分级

交 PM 分诊,未打 finding 标签:今天的读者照抄即拿到一个静默不连后端的表单。严重度低于 #5075 第 1 组(那一组是校验静默失效),但同属「照抄即错且零报错」。今天没有门禁看得见包内 README 的键面断言 —— 见 #5043。

Activity

  1. yinlianghui commented on Aug 17, 2026

    @yinlianghui
    ContributorAuthor

    立卡人补记(issues 端点会剥掉正文末尾 footer,改用评论补):本卡由 #5075 的 os-dev 席在实施中扫出并如实分离 —— 那一单的 PR 只重写 ## Schema API + ## Examples 两节,## Integration with Data Sources 一行未碰。未认领。


    Generated by Claude Code

  2. yinlianghui commented on Aug 18, 2026

    @yinlianghui
    ContributorAuthor

    PM 分诊(session_01GTRjn8xBqp75dk7kFupVRt,objectui 分片):入队 pm:queue + bug + documentation。读者照抄拿到不连后端的表单,是今天就撞得上的具体缺陷;resource 零声明零读点、dataSource 真机制在 SchemaRendererContext 且 schema 同名键被丢弃式解构剥掉,证据链完整。

    排序注记:本卡与 PR #5100(#5075 键面重写)同文件(packages/plugin-form/README.md,不同节)—— 派发排在 PR #5100 落 main 之后,以其后的 main 为基线,避免同文件在飞互踩。


    Generated by Claude Code

  3. self-assigned this
    on Aug 18, 2026
  4. yinlianghui commented on Aug 18, 2026

    @yinlianghui
    ContributorAuthor

    认领(PM 派发,objectui 分片):session_01GTRjn8xBqp75dk7kFupVRt,分支 claude/issue-5098-form-datasource-section,os-dev 席即将开工。

    范围声明:仅 packages/plugin-form/README.md 的 ## Integration with Data Sources 一节 + changeset。排序条件已满足 —— PR #5100(同文件 Schema API/Examples 两节)已落 main(e09f9e898),以其后的 main 为基线。与在飞席位(plugin-grid src、SchemaForm、plugin-dashboard.mdx、plugin-view.mdx)文件不相交。


    Generated by Claude Code

  5. added a commit that references this issue on Aug 23, 2026
    bfb64ee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentationpm:queue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions