Class: Binco::MaterializeFormBuilder

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Defined in:
app/helpers/binco/materialize_form_builder.rb

Instance Method Summary collapse

Instance Method Details

#check_box(method, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object



75
76
77
78
# File 'app/helpers/binco/materialize_form_builder.rb', line 75

def check_box(method, options = {}, checked_value = "1", unchecked_value = "0")
  options = add_class_to_options('checkbox', options)
  super method, options, checked_value, unchecked_value
end

#checkbox_group(options = {}, &block) ⇒ Object



95
96
97
98
# File 'app/helpers/binco/materialize_form_builder.rb', line 95

def checkbox_group(options = {}, &block)
  options = add_class_to_options('checkbox', options)
  group_tag options, &block
end

#collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {}, &block) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/binco/materialize_form_builder.rb', line 18

def collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {}, &block)
  if block_given?
    super(method, collection, value_method, text_method, options, html_options, &block)
  else
    super method, collection, value_method, text_method, options, html_options do |b|
      group_tag class: 'checkbox' do
        b.label do
          b.check_box + b.text
        end
      end
    end
  end
end

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

Since select2 support multiple choices (checkboxes)



33
34
35
36
37
# File 'app/helpers/binco/materialize_form_builder.rb', line 33

def collection_check_boxes2(method, collection, value_method, text_method, options = {}, html_options = {})
  html_options ||= {}
  html_options[:multiple] = 'multiple'
  collection_select2 method, collection, value_method, text_method, options, html_options
end

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



39
40
41
# File 'app/helpers/binco/materialize_form_builder.rb', line 39

def collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
  super method, collection, value_method, text_method, options, html_options
end

#collection_select2(method, collection, value_method, text_method, options = {}, html_options = {}, &block) ⇒ Object



43
44
45
46
# File 'app/helpers/binco/materialize_form_builder.rb', line 43

def collection_select2(method, collection, value_method, text_method, options = {}, html_options = {}, &block)
  html_options = add_class_to_options('select2-rails', html_options)
  collection_select(method, collection, value_method, text_method, options, html_options)
end

#collection_select_originalObject



3
# File 'app/helpers/binco/materialize_form_builder.rb', line 3

alias_method :collection_select_original, :collection_select

#datepicker(method, options = {}) ⇒ Object



60
61
62
63
# File 'app/helpers/binco/materialize_form_builder.rb', line 60

def datepicker(method, options = {})
  options = add_data_to_options({ provide: 'datepicker' }, options)
  text_field(method, options)
end

#email_field(name, options = {}) ⇒ Object



48
49
50
# File 'app/helpers/binco/materialize_form_builder.rb', line 48

def email_field(name, options = {})
  super name, options
end

#form_group(options = {}, &block) ⇒ Object



85
86
87
88
# File 'app/helpers/binco/materialize_form_builder.rb', line 85

def form_group(options = {}, &block)
  options = add_class_to_options('input-field', options)
  group_tag options, &block
end

#input_group(options = {}, &block) ⇒ Object



100
101
102
103
# File 'app/helpers/binco/materialize_form_builder.rb', line 100

def input_group(options = {}, &block)
  options = add_class_to_options('input-group', options)
  group_tag options, &block
end

#number_field(name, options = {}) ⇒ Object



52
53
54
# File 'app/helpers/binco/materialize_form_builder.rb', line 52

def number_field(name, options = {})
  super name, options
end

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



56
57
58
# File 'app/helpers/binco/materialize_form_builder.rb', line 56

def password_field(name, options = {})
  super name, options
end

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



70
71
72
73
# File 'app/helpers/binco/materialize_form_builder.rb', line 70

def radio_button(method, tag_value, options = {})
  options = add_class_to_options('radio', options)
  super method, tag_value, options
end

#radio_group(options = {}, &block) ⇒ Object



90
91
92
93
# File 'app/helpers/binco/materialize_form_builder.rb', line 90

def radio_group(options = {}, &block)
  options = add_class_to_options('radio', options)
  group_tag options, &block
end

#select(method, choices = nil, options = {}, html_options = {}, &block) ⇒ Object



14
15
16
# File 'app/helpers/binco/materialize_form_builder.rb', line 14

def select(method, choices = nil, options = {}, html_options = {}, &block)
  super method, choices, options, html_options, &block
end

#select_originalObject



4
# File 'app/helpers/binco/materialize_form_builder.rb', line 4

alias_method :select_original, :select

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



80
81
82
83
# File 'app/helpers/binco/materialize_form_builder.rb', line 80

def submit(value = nil, options = {})
  options = add_class_to_options('btn', options)
  super value, options
end

#telephone_field(name, options = {}) ⇒ Object



10
11
12
# File 'app/helpers/binco/materialize_form_builder.rb', line 10

def telephone_field(name, options = {})
  super name, options
end

#text_area(method, options = {}) ⇒ Object



65
66
67
68
# File 'app/helpers/binco/materialize_form_builder.rb', line 65

def text_area(method, options = {})
  options = add_class_to_options('materialize-textarea', options)
  super(method, options)
end

#text_field(name, options = {}) ⇒ Object



6
7
8
# File 'app/helpers/binco/materialize_form_builder.rb', line 6

def text_field(name, options = {})
  super name, options
end