Buttons
When you're building forms, use Bullet Train's Field Partials for your form fields. They DRY-up all the presentation logic without needing a third-party dependency like Formtastic.
Read much more about them in the extensive developer documentation.
Read much more about them in the extensive developer documentation.
Samples
Single Basic Button
1.4ms
1109 allocs
View Source
<%= render "shared/fields/buttons", form: form, method: :button_value %>
Multiple Buttons
1.6ms
1133 allocs
View Source
<%= render "shared/fields/buttons", form: form, method: :multiple_button_values, options: {multiple: true} %>
Boolean Button
0.8ms
750 allocs
View Source
<%= render "shared/fields/buttons", form: form, method: :boolean_button_value %>
Options
| Name | Required | Type | Default | Description |
|---|---|---|---|---|
form |
ActionView::Helpers::FormBuilder |
Reference to the form object |
||
method |
String |
Attribute of the model |
||
options |
Hash |
{} |
Options passed directly to the underlying Rails form field helper. |
|
other_options |
Hash |
{} |
Additional options for things like hiding labels, displaying specific error messages, etc. |
|
other_options[:icon] |
String |
Display an icon. |
||
other_options[:label] |
String |
Display a specific field label. |
||
other_options[:hide_label] |
Boolean |
false |
Hide the field label. |
|
other_options[:help] |
String |
Display a specific help string. |
||
other_options[:error] |
String |
Display a specific error string. |