Class: FoundationRailsHelperMod::FormBuilder

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Includes:
ActionView::Helpers::TagHelper
Defined in:
lib/foundation_rails_helper_mod/form_builder.rb

Instance Method Summary collapse

Instance Method Details

#autocomplete(attribute, url, options = {}) ⇒ Object



66
67
68
69
70
71
72
# File 'lib/foundation_rails_helper_mod/form_builder.rb', line 66

def autocomplete(attribute, url, options = {})
  field attribute, options do |options|
    autocomplete_field(attribute, url, options.merge(:update_elements => options[:update_elements],
                                                     :min_length => 0,
                                                     :value => object.send(attribute)))
  end
end

#check_box(attribute, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/foundation_rails_helper_mod/form_builder.rb', line 17

def check_box(attribute, options = {})
  html = custom_label(attribute, options[:label], options[:label_options]) do
    options.delete(:label)
    options.delete(:label_options)
    super(attribute, options)
  end

  html += (:p, options[:description], :class => 'description') if options[:description].present?
  html += error_and_hint(attribute, options)
end

#date_select(attribute, options = {}, html_options = {}) ⇒ Object



47
48
49
50
51
# File 'lib/foundation_rails_helper_mod/form_builder.rb', line 47

def date_select(attribute, options = {}, html_options = {})
  field attribute, html_options do |html_options|
    super(attribute, options, html_options.merge(:autocomplete => :off))
  end
end

#datetime_select(attribute, options = {}) ⇒ Object



41
42
43
44
45
# File 'lib/foundation_rails_helper_mod/form_builder.rb', line 41

def datetime_select(attribute, options = {})
  field attribute, options do |options|
    super(attribute, {}, options.merge(:autocomplete => :off))
  end
end

#password_field(attribute, options = {}) ⇒ Object



35
36
37
38
39
# File 'lib/foundation_rails_helper_mod/form_builder.rb', line 35

def password_field(attribute, options = {})
  field attribute, options do |options|
    super(attribute, options.merge(:autocomplete => :off))
  end
end

#radio_button(attribute, tag_value, options = {}) ⇒ Object



28
29
30
31
32
33
# File 'lib/foundation_rails_helper_mod/form_builder.rb', line 28

def radio_button(attribute, tag_value, options = {})
  options[:for] ||= "#{object.class.to_s.downcase}_#{attribute}_#{tag_value}"
  l = label(attribute, options)
  c = super(attribute, tag_value, options)
  l.gsub(/(for=\"\w*\"\>)/, "\\1#{c} ").html_safe
end

#select(attribute, choices, options = {}, html_options = {}) ⇒ Object



59
60
61
62
63
64
# File 'lib/foundation_rails_helper_mod/form_builder.rb', line 59

def select(attribute, choices, options = {}, html_options = {})
  field attribute, options do |options|
    html_options[:autocomplete] ||= :off
    super(attribute, choices, options, html_options)
  end
end

#submit(value = nil, options = {}) ⇒ Object



74
75
76
77
# File 'lib/foundation_rails_helper_mod/form_builder.rb', line 74

def submit(value=nil, options={})
  options[:class] ||= "small radius success button"
  super(value, options)
end

#time_zone_select(attribute, options = {}) ⇒ Object



53
54
55
56
57
# File 'lib/foundation_rails_helper_mod/form_builder.rb', line 53

def time_zone_select(attribute, options = {})
  field attribute, options do |options|
    super(attribute, {}, options.merge(:autocomplete => :off))
  end
end