forms_helper.rb
3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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
127
128
129
require_dependency 'forms_helper'
module FormsHelper
protected
module ResponsiveMethods
# add -inline class
def labelled_radio_button( human_name, name, value, checked = false, options = {} )
return super unless theme_responsive?
options[:id] ||= 'radio-' + FormsHelper.next_id_number
<<<<<<< HEAD
content_tag( 'label', radio_button_tag( name, value, checked, options ) + ' ' +
human_name, for: options[:id], class: 'radio-inline' )
=======
content_tag :div, class:'radio-inline' do
content_tag :label, for: options[:id] do
[
radio_button_tag(name, value, checked, options),
' ',
human_name,
].safe_join
end
end
>>>>>>> 2ef3a43... responsive: fix html_safe issues
end
# add -inline class
def labelled_check_box( human_name, name, value = "1", checked = false, options = {} )
return super unless theme_responsive?
options[:id] ||= 'checkbox-' + FormsHelper.next_id_number
<<<<<<< HEAD
hidden_field_tag(name, '0') +
content_tag( 'label', check_box_tag( name, value, checked, options ) + ' ' + human_name, for: options[:id], class: 'checkbox-inline')
=======
[
hidden_field_tag(name, '0'),
content_tag(:div, class:'checkbox-inline') do
content_tag :label, for: options[:id] do
[
check_box_tag(name, value, checked, options),
' ',
human_name,
].safe_join
end
end
].safe_join
>>>>>>> 2ef3a43... responsive: fix html_safe issues
end
def submit_button(type, label, html_options = {})
return super unless theme_responsive?
bt_cancel = html_options[:cancel] ? button(:cancel, _('Cancel'), html_options[:cancel]) : ''
button_size = html_options[:size] || 'default'
size_class = if button_size == 'default' then '' else 'btn-'+button_size end
html_options.delete :size if html_options[:size]
html_options[:class] = [html_options[:class], 'submit'].compact.join(' ')
the_class = "btn #{size_class} btn-default with-text icon-#{type}"
if html_options.has_key?(:class)
the_class << ' ' << html_options[:class]
end
html_options.delete(:cancel)
bt_submit = button_tag(label, html_options.merge(class: the_class))
<<<<<<< HEAD
=======
[bt_submit + bt_cancel].safe_join
end
>>>>>>> 2ef3a43... responsive: fix html_safe issues
bt_submit + bt_cancel
end
<<<<<<< HEAD
%w[select select_tag text_field_tag number_field_tag password_field_tag].each do |method|
define_method method do |*args, &block|
#return super(*args, &block) unless theme_responsive?
options = args.extract_options!
if options['class']
options['class'] = "#{options['class']} form-control"
else
options[:class] = "#{options[:class]} form-control"
end
super(*(args << options), &block)
=======
%w[
select_tag
text_field_tag text_area_tag
number_field_tag password_field_tag url_field_tag email_field_tag
month_field_tag date_field_tag
].each do |method|
define_method method do |name, value=nil, options={}, &block|
responsive_add_field_class! options
super(name, value, options, &block).html_safe
>>>>>>> 2ef3a43... responsive: fix html_safe issues
end
end
%w[select_month select_year].each do |method|
define_method method do |date, options={}, html_options={}|
<<<<<<< HEAD
if html_options['class']
html_options['class'] = "#{html_options['class']} form-control"
else
html_options[:class] = "#{html_options[:class]} form-control"
end
super date, options, html_options
=======
responsive_add_field_class! html_options
super(date, options, html_options).html_safe
>>>>>>> 2ef3a43... responsive: fix html_safe issues
end
end
end
include ResponsiveChecks
prepend ResponsiveMethods
end