Class: FoundationRailsHelper::FormBuilder

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

Instance Method Summary collapse

Instance Method Details

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



62
63
64
65
66
67
68
# File 'lib/foundation_rails_helper/form_builder.rb', line 62

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 = {}, checked_value = "1", unchecked_value = "0") ⇒ Object



16
17
18
19
20
21
22
# File 'lib/foundation_rails_helper/form_builder.rb', line 16

def check_box(attribute, options = {}, checked_value = "1", unchecked_value = "0")
  custom_label(attribute, options[:label], options[:label_options]) do
    options.delete(:label)
    options.delete(:label_options)
    super(attribute, options, checked_value, unchecked_value)
  end + error_and_hint(attribute, options)
end

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



43
44
45
46
47
# File 'lib/foundation_rails_helper/form_builder.rb', line 43

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



37
38
39
40
41
# File 'lib/foundation_rails_helper/form_builder.rb', line 37

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

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



31
32
33
34
35
# File 'lib/foundation_rails_helper/form_builder.rb', line 31

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



24
25
26
27
28
29
# File 'lib/foundation_rails_helper/form_builder.rb', line 24

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

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



55
56
57
58
59
60
# File 'lib/foundation_rails_helper/form_builder.rb', line 55

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



70
71
72
73
# File 'lib/foundation_rails_helper/form_builder.rb', line 70

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

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



49
50
51
52
53
# File 'lib/foundation_rails_helper/form_builder.rb', line 49

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