← Back to Skills Marketplace
bovinphang

Form Handling

by Bovin Phang · GitHub ↗ · v2.5.0 · MIT-0
cross-platform ✓ Security Clean
38
Downloads
0
Stars
1
Active Installs
1
Versions
Install in OpenClaw
/install fec-form-handling
Description
Use when building or reviewing substantial forms with React Hook Form, Zod schemas, typed validation, dynamic fields, controlled third-party inputs, file upl...
README (SKILL.md)

表单处理

Purpose

管理表单状态、校验和提交,避免复杂表单输入卡顿。

Procedure

  1. 先判断复杂度:10+ 字段、动态字段、联动校验、文件上传、多步流程或输入卡顿时使用 React Hook Form + Zod;极简表单可用原生受控组件。
  2. 用 Zod 定义运行时 schema,并用 z.infer 推导 TypeScript 类型;schema 是外部输入边界,不要只写 TS 类型。
  3. useForm 必须提供 defaultValues,通过 zodResolver 统一校验;错误提示用 aria-invalidaria-describedbyrole="alert"
  4. 第三方受控组件用 Controller,原生 input 优先 register;不要混用两套状态源。
  5. 提交时处理 loading、服务端错误、重复提交和 reset;大型表单用局部订阅和子组件隔离控制重渲染。

Quick Start

import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { z } from "zod";

const loginSchema = z.object({
  email: z.string().email("请输入有效的邮箱地址"),
  password: z.string().min(8, "密码至少 8 个字符"),
});

type LoginForm = z.infer\x3Ctypeof loginSchema>;

export function LoginFormView() {
  const {
    register,
    handleSubmit,
    formState: { errors, isSubmitting },
  } = useForm\x3CLoginForm>({
    resolver: zodResolver(loginSchema),
    defaultValues: { email: "", password: "" },
  });

  return (
    \x3Cform onSubmit={handleSubmit((data) => api.login(data))} noValidate>
      \x3Clabel htmlFor="email">邮箱\x3C/label>
      \x3Cinput id="email" {...register("email")} aria-invalid={!!errors.email} />
      {errors.email && \x3Cspan role="alert">{errors.email.message}\x3C/span>}

      \x3Clabel htmlFor="password">密码\x3C/label>
      \x3Cinput id="password" type="password" {...register("password")} />
      {errors.password && \x3Cspan role="alert">{errors.password.message}\x3C/span>}

      \x3Cbutton disabled={isSubmitting}>
        {isSubmitting ? "提交中..." : "提交"}
      \x3C/button>
    \x3C/form>
  );
}

Detailed References

涉及 ControlleruseFieldArray、联动校验、文件上传、多步表单、异步校验和性能模式时,加载 references/advanced-form-patterns.md

Constraints

  • React Hook Form 默认非受控;只有第三方受控组件才用 Controller
  • defaultValues 必须完整,避免 undefined 触发受控/非受控警告。
  • reset() 应传服务器返回或明确的完整默认对象。
  • 异步校验必须 debounce 或放到提交边界,避免每次键入请求。
  • Zod refine / superRefinepath 必须指向实际字段。

Expected Output

产出类型安全、可访问、提交状态明确的表单;复杂字段和文件上传有 schema 约束,输入过程无明显卡顿,服务端错误能回填到用户可理解的位置。

Usage Guidance
Reasonable to install if you want help with complex form design or review. Be aware it may activate for ordinary form-related frontend requests, so check that it is relevant before following its guidance.
Capability Assessment
Purpose & Capability
The stated purpose is helping build or review substantial forms, and the supplied evidence shows no unrelated high-impact capabilities, credential handling, destructive actions, or exfiltration behavior.
Instruction Scope
The activation wording is broad enough to trigger on many frontend form tasks, but that is a scoping and usability concern rather than evidence of unsafe behavior.
Install Mechanism
No supplied artifact or scan evidence indicates postinstall execution, hidden setup commands, dependency abuse, or automatic runtime behavior.
Credentials
No evidence indicates access to local files, sessions, credentials, network services, private profiles, or other sensitive environment resources.
Persistence & Privilege
No evidence indicates persistence, background workers, privilege escalation, scheduled execution, or mutation of agent configuration.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install fec-form-handling
  3. After installation, invoke the skill by name or use /fec-form-handling
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v2.5.0
- Major documentation update: SKILL.md expanded with clear purpose, procedure, quick start example, detailed constraints, and advanced references. - Clarifies scenarios for using React Hook Form and Zod, especially for substantial forms or performance needs. - Provides best practices for typed validation, accessibility, error handling, and state management. - Includes a code sample for rapid onboarding and typical form setup. - Outlines expected outcomes for complex form handling and common pitfalls to avoid.
Metadata
Slug fec-form-handling
Version 2.5.0
License MIT-0
All-time Installs 1
Active Installs 1
Total Versions 1
Frequently Asked Questions

What is Form Handling?

Use when building or reviewing substantial forms with React Hook Form, Zod schemas, typed validation, dynamic fields, controlled third-party inputs, file upl... It is an AI Agent Skill for Claude Code / OpenClaw, with 38 downloads so far.

How do I install Form Handling?

Run "/install fec-form-handling" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Form Handling free?

Yes, Form Handling is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Form Handling support?

Form Handling is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Form Handling?

It is built and maintained by Bovin Phang (@bovinphang); the current version is v2.5.0.

💬 Comments