Class: ZurbRush::FormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- ZurbRush::FormBuilder
- 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
- #field(field_name, options = {}) ⇒ Object
- #input(field_name, options = {}) ⇒ Object
- #time_zone_field(field_name, options) ⇒ Object
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, = {}) field_name = field_name.to_s field_type = .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, ) end |
#input(field_name, options = {}) ⇒ Object
13 14 15 16 |
# File 'lib/zurb-rush/form_builder.rb', line 13 def input(field_name, = {}) label_text = .delete(:label) label(field_name, label_text) + field(field_name, ) 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, ) time_zone_select(field_name, ) end |