- Helper for horizontal form
- Input groups
- Custom submit button
Last active
August 29, 2015 14:11
-
-
Save maxivak/9a6cb31950a8f4e37949 to your computer and use it in GitHub Desktop.
simple_form and bootstrap 3 examples
app/helpers/forms/forms_helper.rb
module Forms::FormsHelper
def horizontal_simple_form_for(resource, options = {}, &block)
options[:html] ||= {}
# class
options[:html][:class] ||= []
if options[:html][:class].is_a? Array
options[:html][:class] << 'form-horizontal'
else
options[:html][:class] << ' form-horizontal'
end
options[:html][:role] = 'form'
options[:wrapper] = :horizontal_form
options[:wrapper_mappings] = {
check_boxes: :horizontal_radio_and_checkboxes,
radio_buttons: :horizontal_radio_and_checkboxes,
file: :horizontal_file_input,
boolean: :horizontal_boolean
}
simple_form_for(resource, options, &block)
end
end
app/views/orders/_form.html.haml
= horizontal_simple_form_for @order do |f|
= f.error_notification
= f.input :textfield1
= f.button :submit, 'Save', :class=> 'btn-primary'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment