Module: ActionView::Helpers::FormHelper

Defined in:
lib/bootstrap-form/form_helper.rb

Instance Method Summary collapse

Instance Method Details

#bootstrap_clearfix_wrap(object_name, method, content, options = {}) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/bootstrap-form/form_helper.rb', line 24

def bootstrap_clearfix_wrap(object_name, method, content, options={})
  error_messages = options[:object].errors[method]
  clearfix_tag = error_messages.empty? ? 'clearfix' : 'clearfix error'
  (:div, label(object_name, method) +
      (:div, content + inline_help_tag(error_messages), :class => 'input'),
      :class => clearfix_tag)
end

#bootstrap_collection_select(object_name, method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ Object



12
13
14
# File 'lib/bootstrap-form/form_helper.rb', line 12

def bootstrap_collection_select(object_name, method, collection, value_method, text_method, options = {}, html_options = {})
  bootstrap_clearfix_wrap(object_name, method, collection_select(object_name, method, collection, value_method, text_method, options.dup, html_options), options)
end

#bootstrap_file_field(object_name, method, options = {}) ⇒ Object



16
17
18
# File 'lib/bootstrap-form/form_helper.rb', line 16

def bootstrap_file_field(object_name, method, options={})
  bootstrap_clearfix_wrap(object_name, method, file_field(object_name, method, options.dup), options)
end

#bootstrap_password_field(object_name, method, options = {}) ⇒ Object



8
9
10
# File 'lib/bootstrap-form/form_helper.rb', line 8

def bootstrap_password_field(object_name, method, options={})
  bootstrap_clearfix_wrap(object_name, method, password_field(object_name, method, options.dup), options)
end

#bootstrap_text_area(object_name, method, options = {}) ⇒ Object



20
21
22
# File 'lib/bootstrap-form/form_helper.rb', line 20

def bootstrap_text_area(object_name, method, options={})
  bootstrap_clearfix_wrap(object_name, method, text_area(object_name, method, options.dup), options)
end

#bootstrap_text_field(object_name, method, options = {}) ⇒ Object



4
5
6
# File 'lib/bootstrap-form/form_helper.rb', line 4

def bootstrap_text_field(object_name, method, options={})
  bootstrap_clearfix_wrap(object_name, method, text_field(object_name, method, options.dup), options)
end

#inline_help_tag(messages) ⇒ Object



32
33
34
35
# File 'lib/bootstrap-form/form_helper.rb', line 32

def inline_help_tag(messages)
  message_span = ActiveSupport::SafeBuffer.new(" #{messages.join(',')}")
  messages.empty? ? '' : (:span, message_span, :class => 'help-inline')
end