components/form
입력과 폼 · 17 / 64

Form

ui.widgets.FormOf(T)

타입이 지정된 폼 상태, 필드 메타데이터, 검증 시점.

BEHAVIOR CONTRACT

값, dirty / touched, 오류, on_blur / on_submit 검증은 노드 콜백이 아니라 폼에 있습니다.

RECORDED INTERACTION

harness가 Submit을 클릭하면 required 필드에 검증 결과가 표시됩니다.

examples/storybook/stories.zig:3140
pub fn buildForm(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
    const a = cx.allocator;
    const c = try col(cx, 12);
    _ = try ui.widgets.FormOf(DemoForm).create(scope, .{ .name = "", .email = "" }, .{ .trigger = .on_blur });
    // 表单字段 UI 用 Input 展示(FormOf 管校验状态;此 story 重在展示字段布局)
    try c.appendChild(a, try W.Input(.{ .label_text = "Name", .placeholder = "Full name", .width = 320, .required = true }).mount(scope, cx));
    try c.appendChild(a, try W.Input(.{ .label_text = "Email", .input_type = .email, .placeholder = "you@example.com", .width = 320, .required = true }).mount(scope, cx));
    try c.appendChild(a, try W.Button(.{ .label = "Submit", .variant = .primary }).mount(scope, cx));
    return c;
}
GitHub에서 소스 보기examples/storybook/stories.zig:3140

Storybook에 있는 이 story의 원본 코드입니다(zenit 5f9add5+wip 2026-09-30). W는 ui.widgets이며, col / row / label은 Storybook 내부의 작은 레이아웃 헬퍼입니다.

zenit · 이중 라이선스오픈 소스 프로젝트는 GPL-3.0-only로 무료 사용할 수 있으며, 비공개 소스나 상용 제품에는 상용 라이선스가 필요합니다.작성자 연락처: zongyi.xzy#gmail.com (#을 @로 바꾸세요)zenit 5f9add5+wip 2026-09-30