Define a form / order block
set_formAttach a form viewers can fill in (sign-ups, orders, bookings, leads) to a page: you only define the fields; the platform renders the form in the reading page (mobile-friendly, validated), and each submission lands as a row in this data table, readable with list_data_rows. No form code needed (a plain posting to ./_data/ works too). Idempotent: creates the table when absent, otherwise replaces the whole field definition (rows already collected are kept). fields: at most 20 items of { key, label, type, required?, options?, min?, max?, visibility?, fence? … }; nine types: text (single line), textarea, select (options), multiselect (options, stored joined with 、), number (min / max), phone (11-digit mobile), email, image (check-in photos / collected material; max = how many images, 1–9, default 1; visibility = author — only you and the submitter see the images (default) — or all — shown with the row to every reader, for a check-in wall; viewers pick photos on their phone, the platform compresses them, strips location metadata and runs image moderation, and a row with a flagged image is visible only to you; list_data_rows gives each image a one-hour URL under images), location (location check-in; at most one per table; fence = { lat, lng, radius_m, name? } sets the check-in point, coordinates in GCJ-02 (as picked on Tencent / Amap maps), radius 20–5000 m; without fence there is no range limit and the field just records where viewers checked in (they pick a nearby place and the field stores its name); max_accuracy_m is the accuracy requirement, default 100 m (1000 without fence); out_of_range = reject — out-of-range check-ins are refused (default) — or hold — kept for you to confirm; window = { start, end } is the check-in time window; require_identity defaults to true, meaning viewers check in with their WeChat identity and the table first needs set_data identity=wechat. The page calls space.location({ table }) to get a ticket, puts it in this field and then appends; the row stores the distance in metres plus _loc_in_range / _loc_accuracy_m / _loc_source, never the coordinates; if you really need coordinates pass keep_coords=true — they then appear only to you under location in list_data_rows and are cleared automatically after 30 days). amount is optional and only displays a price: { unit_price_cents, qty_field? (which number field holds the quantity) }; the platform computes the total as unit price × quantity and writes it into each row as _amount_cents — no money is collected (payment guidance and real payment are separate tools). Each row also carries _form_rev (the table version at submission time). Viewer write-back is open by default (append_open=true); pass false to close it. Submissions remain rate-limited and text is moderated first: approved rows appear for viewers on refresh, flagged rows are visible only to you in list_data_rows. Preview and presenter sessions never submit; the author and other workspace members can submit on the live page while signed in, and their rows record which member (by) without counting as a visitor. With members_only=true only members can submit and visitors do not see the form. Page read-back, withdrawal and unknown-column warnings work as described under set_data (_row_id / _at / _status / _mine / _by). Optional notify_emails sends an email for every new approved submission (up to 3 addresses; each new address first gets a confirmation email and only receives notifications after confirming; with an email field, replying reaches the submitter). Share the page after defining the form; the page does not need republishing.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | 表名,例如 signup、orders;提交的行落在这张表 | |
| title | No | 表单标题,也是查看页里那枚按钮的字,例如「报名」「下单」;缺省「填写」 | |
| amount | No | 显示金额;不传 = 不显示金额 | |
| fields | Yes | 字段定义,按顺序渲染 | |
| revision | No | 可选:get_data 返回的当前 revision,传了就防并发(不一致 409);不传按当前修订写 | |
| append_open | No | 读者写回开关,缺省 true;false = 表单不显示、提交被拒 | |
| proposal_id | Yes | ||
| members_only | No | Accept submissions from workspace members only (visitors do not see the form and get 403); omitted = keep the current value, false for a new table | |
| notify_emails | No | 新提交邮件通知:最多 3 个收件邮箱,读者每交一行(过审)发一封邮件给它们,附全部字段;新地址先收确认信、点确认后才发;[] = 不再通知。可单独传 |