Class: ZurbRush::FormBuilder

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Defined in:
lib/zurb-rush/form_builder.rb

Constant Summary collapse

FIELD_NAME_MATCHERS =
{
  /password/ => :password,
  /search/ => :search,
  /email/ => :email,
  /phone/ => :phone,
  /fax/ => :phone,
  /url/ => :url,
  /time_zone/ => :time_zone
}

Instance Method Summary collapse

Instance Method Details

#field(field_name, options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/zurb-rush/form_builder.rb', line 18

def field(field_name, options = {})
  field_name = field_name.to_s

  field_type = options.delete(:as)
  field_type ||= FIELD_NAME_MATCHERS.to_a.select { |matcher, type| matcher === field_name }.map { |_, type| type }.first
  field_type ||= :text

  send("#{field_type}_field", field_name, options)
end

#input(field_name, options = {}) ⇒ Object



13
14
15
16
# File 'lib/zurb-rush/form_builder.rb', line 13

def input(field_name, options = {})
  label_text = options.delete(:label)
  label(field_name, label_text) + field(field_name, options)
end

#time_zone_field(field_name, options) ⇒ Object



28
29
30
# File 'lib/zurb-rush/form_builder.rb', line 28

def time_zone_field(field_name, options)
  time_zone_select(field_name, options)
end