Form
ui.widgets.FormOf(T)型付きのフォーム状態、フィールドのメタ情報、検証タイミング。
BEHAVIOR CONTRACT
値、dirty / touched、エラー、on_blur / on_submit の検証はフォームが持ち、ノードのコールバックに散らばりません。
RECORDED INTERACTION
harness が Submit をクリックし、required フィールドに検証結果が表示されます。
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;
}Storybook にあるこの story のコードそのままです(zenit 5f9add5+wip 2026-09-30)。W は ui.widgets のことで、col / row / label は Storybook 内の小さなレイアウトヘルパーです。