Field Set
Groups a label, one or more fields, and optional help text into a single form unit.
| Prop | Type | Default | Notes |
|---|---|---|---|
stack |
String | "column" |
One of STACKS: "column" (default) stacks label โ fields โ helptext vertically; "row" puts the label in a 110px left column, vertically centered, with field + helptext on the right. |
**html_options |
Hash | โ | Extra HTML attributes for the root `<div>`. |
Slots: fields helptext label
Default
1 | <%= render FieldSetComponent.new do |f| %> |
2 | <% f.with_label(text: "Label", for: "field") %> |
3 | <% f.with_field do %> |
4 | <%= render TextFieldComponent.new(name: "field", id: "field") %> |
5 | <% end %> |
6 | <% end %> |
Multiple fields
1 | <%= render FieldSetComponent.new do |f| %> |
2 | <% f.with_label(text: "Name", for: "field") %> |
3 | <% f.with_field do %> |
4 | <%= render TextFieldComponent.new(name: "first", placeholder: "First name") %> |
5 | <% end %> |
6 | <% f.with_field do %> |
7 | <%= render TextFieldComponent.new(name: "last", placeholder: "Last name") %> |
8 | <% end %> |
9 | <% end %> |
Row
1 | <%= render FieldSetComponent.new(stack: "row") do |f| %> |
2 | <% f.with_label(text: "Label", for: "field") %> |
3 | <% f.with_field do %> |
4 | <%= render TextFieldComponent.new(name: "field", id: "field") %> |
5 | <% end %> |
6 | <% end %> |
Row with helptext
This is some helptext that can span upto 2 lines.
1 | <%= render FieldSetComponent.new(stack: "row") do |f| %> |
2 | <% f.with_label(text: "Label", for: "field") %> |
3 | <% f.with_field do %> |
4 | <%= render TextFieldComponent.new(name: "field", id: "field") %> |
5 | <% end %> |
6 | <% f.with_helptext { "This is some helptext that can span upto 2 lines." } %> |
7 | <% end %> |
With helptext
This is some helptext that can span upto 2 lines.
1 | <%= render FieldSetComponent.new do |f| %> |
2 | <% f.with_label(text: "Label", for: "field") %> |
3 | <% f.with_field do %> |
4 | <%= render TextFieldComponent.new(name: "field", id: "field") %> |
5 | <% end %> |
6 | <% f.with_helptext { "This is some helptext that can span upto 2 lines." } %> |
7 | <% end %> |
With info
1 | <%= render FieldSetComponent.new do |f| %> |
2 | <% f.with_label(text: "Label", info: true, for: "field") %> |
3 | <% f.with_field do %> |
4 | <%= render TextFieldComponent.new(name: "field", id: "field") %> |
5 | <% end %> |
6 | <% end %> |