Reach for manual form controls when you want exact field layout or when the data shape does not justify a generated form.
paw.Formpaw.Inputpaw.Checkboxpaw.Selectpaw.MultiSelectpaw.BitMaskAPI 接口 |
Description 说明 |
|---|---|
Form |
The top-level <form> wrapper. It defaults to POST and a two-column responsive layout. 最顶层的 <form> 包装器,默认使用 POST 和两列响应式布局。 |
Input + InputTypeHidden/InputTypePassword |
Manual text, hidden, password, file, date, time, and numeric inputs. 手写文本、隐藏、密码、文件、日期、时间和数值输入。 |
Checkbox |
Single boolean checkbox input. 单个布尔复选框输入。 |
Textarea |
Multi-line text input with configurable height. 支持配置高度的多行文本输入。 |
Select + SelectOption |
Single-select control and its option type. 单选下拉控件及其选项类型。 |
MultiSelect |
Bootstrap-based multi-select control for []string style input. 基于 Bootstrap 的多选控件,适合 []string 风格输入。 |
BitMask + BitMaskOption |
Multi-checkbox editor for bitmask-style flags. 用于位掩码标记的多复选框编辑器。 |
TimeFormat, TimeFormatDate, TimeFormatHourMinute |
Shared formatting constants for datetime-local, date, and time inputs. datetime-local、date 和 time 输入共用的格式化常量。 |
The default Form layout automatically wraps a flat list into responsive rows.
paw.Form{
Url: "/manual-submit",
Body: paw.List{
paw.Input{Name: "ID", Type: paw.InputTypeHidden, Value: "42"},
paw.Input{Name: "Name", Label: "Name", Value: "Ada Lovelace"},
paw.Input{Name: "Password", Label: "Password", Type: paw.InputTypePassword},
paw.Checkbox{Name: "Enabled", Label: "Enabled", Checked: true},
paw.Textarea{Name: "Notes", Label: "Notes", Height: 120},
paw.Select{
Name: "Role",
Label: "Role",
Options: []paw.SelectOption{
{Value: "admin"},
{Value: "editor"},
{Value: "viewer"},
},
},
},
}
Disable the default layout when you want to own the row structure yourself.
now := time.Now()
paw.Form{
Method: http.MethodGet,
Url: "/FormsBasic",
DisableDefaultLayout: true,
Body: paw.List{
paw.Row{
ColumnMax: 2,
Columns: paw.List{
paw.MultiSelect{...},
paw.BitMask{...},
},
},
paw.Row{
ColumnMax: 3,
Columns: paw.List{
paw.Input{Type: "datetime-local", Value: now.Format(paw.TimeFormat)},
paw.Input{Type: "date", Value: now.Format(paw.TimeFormatDate)},
paw.Input{Type: "time", Value: now.Format(paw.TimeFormatHourMinute)},
},
},
},
}
When DisableDefaultLayout is false, Form wraps a flat body into its default responsive two-column layout.
For GET forms, Form moves existing query parameters into hidden inputs before rendering the action URL.
Use generated forms for large CRUD screens; keep manual forms for the places where the UI shape is the real source of truth.