Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)8.1k · #12576

webiny-form-model

Skill này làm gì

Skill này hướng dẫn AI của bạn khi xây dựng form trên nền tảng Webiny. Dành cho lập trình viên muốn các trường, bố cục và kiểm tra hợp lệ được định nghĩa rõ ràng theo kiểu khai báo.

Khi nào nên dùng

  • ✓Khi bạn cần định nghĩa trường văn bản, ngày hoặc trường khác cho form Webiny bằng trình tạo.
  • ✓Khi bạn muốn tab, hàng hoặc đường phân cách trong bố cục form.
  • ✓Khi các trường nên hiện, ẩn hoặc kiểm tra hợp lệ tùy theo giá trị của trường khác.

Liên kết skill

https://github.com/webiny/webiny-js/blob/next/skills/user-skills/admin/form-model/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/webiny/webiny-js/blob/next/skills/user-skills/admin/form-model/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Xây dựng form Webiny có tiêu đề, ngày và trạng thái, trong đó trường ngày chỉ hiện khi trạng thái là đã lên lịch.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill cho thấy cách định nghĩa trường bằng một trình tạo chuỗi, sắp xếp bằng trình tạo bố cục, và thêm kiểm tra hợp lệ hoặc quy tắc. Các trường cũng có thể phản ứng với giá trị của trường khác.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Form Model

TL;DR

The Form Model is Webiny's declarative form system. Define fields with a fluent builder API (fields.text(), fields.datetime(), etc.), arrange them with a layout builder (layout.row(), layout.tabs(), etc.), and validate with Zod schemas or imperative rules. Fields support conditional visibility, computed values, reactive context from other fields (.context()), and deeply nested object/list structures with templates (dynamic zones).

Field Types

All fields are created via the fields registry callback. Each builder method returns a chainable builder.

Text

fields.text();

Default renderer: textInput. Value: string | null.

fields.text().label("Title").placeholder("Enter title").required("Title is required")
fields.text().renderer("textarea", { rows: 4 })
fields.text().list().renderer("tags").defaultValue([])
fields.text().list().renderer("textInputs", { addItemLabel: "Add text" })
fields.text().list().renderer("textareas", { addItemLabel: "Add description" })
fields.text().renderer("codeEditor", { language: "html", height: 300 })
fields.text().options([
    { label: "Option A", value: "a" },
    { label: "Option B", value: "b" }
])  // auto-switches to "select" renderer
fields.text().options([...]).renderer("radioButtons")
fields.text().list().options([...]).renderer("checkboxes")

// Dynamic options — callback receives { field, form }, re-evaluated reactively
fields.text().options(({ form }) => {
    const type = form.field("general.type").getValue();
    return getOptionsForType(type);
})

Number

fields.number();

Default renderer: numberInput. Value: number | null. Auto-normalizes to number.

fields.number().label("Count").placeholder("0").required();
fields.number().list().renderer("numberInputs", { addItemLabel: "Add number" });
fields.number().options([
  { label: "Tier 1", value: 100 },
  { label: "Tier 2", value: 200 }
]);

Boolean

fields.boolean();

Default renderer: switch. Value: boolean | null.

fields.boolean().label("Featured").defaultValue(false);

DateTime

fields.datetime();

Default renderer: dateTimeInput. Pick a variant method to set the subtype:

Variant Value Format Example
.dateOnly() "2026-05-01" Holidays, due dates (birthdays: see the birthday picker below)
.timeOnly() "14:30:00" Opening hours
.withTimezone() "2026-05-01T14:30:00+02:00" Events tied to a locale
.withoutTimezone() "2026-05-01T14:30:00.000Z" Timestamps, logs
.monthOnly() "2026-05" Billing cycles
.weekOnly({ startsOn: 1 }) "2026-W18" Sprint planning
.yearOnly({ range: [2020, 2035] }) 2026 (number) Fiscal years
.dateRange() { from: "...", to: "..." } Vacation requests
.multipleDates() ["2026-05-01", "2026-05-03"] Blackout dates
.multipleMonths() ["2026-01", "2026-03"] Seasonal availability
.multipleYears({ range: [2020, 2035] }) [2024, 2025, 2026] Multi-year budgets

Additional chainable methods:

.presets([
    { label: "Today", value: () => new Date() },
    { label: "In a week", value: () => addDays(new Date(), 7) }
])
.displayFormat("dd/MM/yyyy")  // date-fns format tokens
.list()  // switches renderer to "dateTimeInputs"
.dateGte("2026-01-01", "message?")  // value must
Câu hỏi thường gặp

Kiểm tra hợp lệ được thêm thế nào?

Skill hỗ trợ schema Zod cũng như các quy tắc mệnh lệnh đơn giản.

Các trường có thể phụ thuộc lẫn nhau không?

Có. Skill bao phủ hiển thị có điều kiện, vô hiệu hóa và các trường phản ứng với giá trị từ trường khác.

Trình render mặc định là gì?

Với trường văn bản, skill nói trình render mặc định là ô nhập văn bản, và nó có thể chuyển sang các trình render khác như vùng văn bản hoặc danh sách chọn.

Chi tiết

Mô tả gốc của tác giả

Building forms with the FormModel system — field types, renderers, layout, validation, conditional rules, computed fields, and dynamic zones. Use this skill when the developer needs to define form fields with the builder API, choose renderers, build layouts with tabs/rows/separators, add validation (Zod or imperative), use conditional visibility/disable rules, create computed fields, or work with object fields and templates (dynamic zones).

repo: webiny/webiny-js

Độ phổ biến

Sao GitHub
8.1k
Vị trí xếp hạng
#12576
Giấy phép
—
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự