Class: ActionView::Helpers::FormBuilder
Constant Summary
BootstrapFormHelper::FIELD_HELPERS
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#check_box(method, options = {}, checked_value = '1', unchecked_value = '0') ⇒ Object
-
#collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {}, &block) ⇒ Object
-
#collection_radio_buttons(method, collection, value_method, text_method, options = {}, html_options = {}, &block) ⇒ Object
-
#radio_button(method, tag_value, options = {}) ⇒ Object
-
#select(method, choices = nil, options = {}, html_options = {}, &block) ⇒ Object
-
#submit(value = nil, options = {}) ⇒ Object
#button, #button_group, #button_toolbar, #navbar_button
#prepend_class, #squeeze_n_strip
#form_for
#panel
Instance Attribute Details
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
99
100
101
|
# File 'app/helpers/bootstrap_form_helper.rb', line 99
def output_buffer
@output_buffer
end
|
Instance Method Details
#check_box(method, options = {}, checked_value = '1', unchecked_value = '0') ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'app/helpers/bootstrap_form_helper.rb', line 101
def check_box(method, options = {}, checked_value = '1', unchecked_value = '0')
layout_inline = options.delete(:layout).try(:to_sym) == :inline
check_box = proc do
proc = proc do
@template.check_box(@object_name, method, objectify_options(options), checked_value, unchecked_value) +
options[:label]
end
if layout_inline
content_tag :label, class: 'checkbox-inline', &proc
else
content_tag :div, class: 'checkbox' do
content_tag :label, &proc
end
end
end
if horizontal_layout?
content_tag :div, class: 'form-group' do
content_tag :div, class: 'col-sm-offset-3 col-sm-9', &check_box
end
else
check_box.call
end
end
|
#collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {}, &block) ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'app/helpers/bootstrap_form_options_helper.rb', line 31
def collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {}, &block)
check_boxes_proc = proc do
@template.collection_check_boxes(@object_name, method, collection, value_method, text_method,
objectify_options(options), @default_options.merge(html_options),
&block)
end
render_collection(options[:label], &check_boxes_proc)
end
|
41
42
43
44
45
46
47
48
49
|
# File 'app/helpers/bootstrap_form_options_helper.rb', line 41
def collection_radio_buttons(method, collection, value_method, text_method, options = {}, html_options = {}, &block)
radion_buttons_prc = proc do
@template.collection_radio_buttons(@object_name, method, collection, value_method, text_method,
objectify_options(options), @default_options.merge(html_options),
&block)
end
render_collection(options[:label], &radion_buttons_prc)
end
|
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
# File 'app/helpers/bootstrap_form_helper.rb', line 128
def radio_button(method, tag_value, options = {})
layout_inline = options.delete(:layout).try(:to_sym) == :inline
radio_button = proc do
proc = proc do
@template.radio_button(@object_name, method, tag_value, objectify_options(options)) + options[:label]
end
if layout_inline
content_tag :label, class: 'radio-inline', &proc
else
content_tag :div, class: 'radio' do
content_tag :label, &proc
end
end
end
if horizontal_layout?
content_tag :div, class: 'form-group' do
content_tag :div, class: 'col-sm-offset-3 col-sm-9', &radio_button
end
else
radio_button.call
end
end
|
#select(method, choices = nil, options = {}, html_options = {}, &block) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/helpers/bootstrap_form_options_helper.rb', line 8
def select(method, choices = nil, options = {}, html_options = {}, &block)
label_class, field_wrapper = horizontal_layout? ? ['col-sm-3 control-label', true] : []
required = 'required' if html_options.delete(:required)
label_sr_only = 'sr-only' if html_options[:label].is_a?(FalseClass)
html_options[:class] = squeeze_n_strip("form-control #{html_options[:class]}")
label_class = squeeze_n_strip("#{label_class} #{required} #{label_sr_only}")
help_text = (html_options[:help] ? "<span class='help-block text-left'>#{html_options[:help]}</span>" : '').html_safe
select_proc = proc do
@template.select(@object_name,
method,
choices,
objectify_options(options),
@default_options.merge(html_options),
&block) + help_text
end
label_proc = proc { label(method, html_options[:label], class: label_class) }
render_field(field_wrapper, label_proc, select_proc)
end
|
#submit(value = nil, options = {}) ⇒ Object
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'app/helpers/bootstrap_form_helper.rb', line 154
def submit(value=nil, options={})
value, options = nil, value if value.is_a?(Hash)
value ||= submit_default_value
prepend_class(options, 'btn', get_btn_type(options.delete(:type)))
submit_prc = proc { @template.submit_tag(value, options) }
return submit_prc.call unless horizontal_layout?
content_tag :div, class: 'form-group' do
content_tag :div, class: 'col-sm-offset-3 col-sm-9', &submit_prc
end
end
|