Forms
In the end, everything is basically just spreadsheets
Includes a Ruby component and corresponding Rails helper
RubyNitro Kit comes with a custom FormBuilder
that works just like the one you already know except it has a few extras.
Example
<%= form_with model: @post, url: request.path do |f| %>
<%= f.fieldset(legend: "New Post", description: "Tell the world") do |fs| %>
<%= fs.group do %>
<%= f.field :title %>
<%= f.field :category_id, as: :select, options: Category.pluck(:name, :id) %>
<%= f.field :body, as: :textarea, rows: 6 %>
<%= f.field :publish, as: :checkbox, description: "Should we tell the world?" %>
<%= f.field :kind,
as: :radio_group,
options: Post.kinds.map { |k| [k.capitalize, k] },
value: "article" %>
<%= f.submit %>
<% end %>
<% end %>
<% end %>
Usage
| ||
---|---|---|
Property | Default | Description |
**attrs | Arguments for NitroKit::FormBuilder.new() |
Works just like form_with
.
| ||
---|---|---|
Property | Default | Description |
record | ||
**attrs | Arguments for NitroKit::FormBuilder.new() |
Works just like form_for
.
| ||
---|---|---|
Property | Default | Description |
**attrs | Arguments for NitroKit::Fieldset.new() |
| ||
---|---|---|
Property | Default | Description |
field_name | Field name | |
**attrs | Arguments for NitroKit::Field.new() |