Structured Input
Repeatable rows of structured form inputs for metadata, taints, rules, and similar list-shaped data.
Usage Example
@structuredinput.StructuredInput(structuredinput.Config{
ID: "labels",
Name: "labels",
Columns: []structuredinput.Column{
{Key: "key", Label: "Key", Placeholder: "key", Separator: "="},
{Key: "value", Label: "Value", Placeholder: "value"},
},
Entries: []structuredinput.Entry{
{"key": "app", "value": "web"},
{"key": "env", "value": "prod"},
},
})Select Column
Rows can combine text inputs with select columns for enumerated values like Kubernetes taint effects.
Select Column
@structuredinput.StructuredInput(structuredinput.Config{
ID: "taints",
Name: "taints",
Columns: []structuredinput.Column{
{Key: "key", Label: "Key", Placeholder: "key", Separator: "="},
{Key: "value", Label: "Value", Placeholder: "value", Separator: ":"},
{
Key: "effect",
Label: "Effect",
Type: structuredinput.ColumnSelect,
Options: []structuredinput.Option{
{Value: "NoSchedule", Label: "NoSchedule"},
{Value: "PreferNoSchedule", Label: "PreferNoSchedule"},
{Value: "NoExecute", Label: "NoExecute"},
},
},
},
Entries: []structuredinput.Entry{
{"key": "node-role.kubernetes.io/control-plane", "value": "true", "effect": "NoSchedule"},
},
AddActionLabel: "Add taint",
})Empty Starter
With no entries the list starts empty and adds rows from the configured column defaults.
Empty Starter
@structuredinput.StructuredInput(structuredinput.Config{
ID: "rules",
Name: "rules",
Columns: []structuredinput.Column{
{Key: "name", Label: "Name", Placeholder: "rule name"},
{Key: "condition", Label: "Condition", Placeholder: "condition"},
{
Key: "priority",
Label: "Priority",
Type: structuredinput.ColumnSelect,
Options: []structuredinput.Option{
{Value: "high", Label: "High"},
{Value: "medium", Label: "Medium"},
{Value: "low", Label: "Low"},
},
},
},
AddActionLabel: "Add rule",
})API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
ID | string | "" | Unique id for the structured input root. |
Name | string | "" | Base form field name; submitted inputs use name[index][columnKey]. |
Columns | []Column | nil | Column schema for every repeatable row. |
Column.Separator | string | "" | Optional short visual separator rendered after a column, such as = or :. |
Entries | []Entry | nil | Initial row values keyed by column key. |
AddActionLabel | string | "Add row" | Label of the add-row button. |
Disabled | bool | false | Disable controls and hide add/remove actions. |
RootClass | string | "" | Extra classes on the container. |