@@ -4,102 +4,43 @@ class RadioInput < Formtastic::Inputs::RadioInput
4
4
include Base
5
5
include Base ::Choices
6
6
7
- #
8
-
9
7
# TODO Make sure help blocks work correctly.
10
8
# TODO Support .inline
11
9
12
- # def to_html
13
- # control_group_wrapping do
14
- # control_label_html <<
15
- # controls_wrapping do
16
- # choices_group_wrapping do
17
- # collection.map { |choice|
18
- # choice_wrapping(choice_wrapping_html_options(choice)) do
19
- # choice_html(choice)
20
- # end
21
- # }.join("\n").html_safe
22
- # end
23
- # end
24
- # end
25
-
26
- # CHECKBOXES FROM THIS VERSION OF FB
27
- def to_html
28
- control_group_wrapping do
29
- control_label_html <<
30
- # hidden_field_for_all <<
31
- controls_wrapping do
32
- collection . map { |choice |
33
- choice_html ( choice )
34
- } . join ( "\n " ) . html_safe
35
- end
10
+ def to_html
11
+ control_group_wrapping do
12
+ control_label_html <<
13
+ controls_wrapping do
14
+ collection . map { |choice |
15
+ choice_html ( choice )
16
+ } . join ( "\n " ) . html_safe
36
17
end
37
18
end
19
+ end
38
20
39
- def wrapper_html_options
40
- # Formtastic marks these as 'radio' but Bootstrap does something
41
- # with that, so change it to 'radio_buttons'.
42
- super . tap do |options |
43
- options [ :class ] = options [ :class ] . gsub ( "radio" , "radio_buttons" )
44
- end
21
+ def wrapper_html_options
22
+ # Formtastic marks these as 'radio' but Bootstrap does something
23
+ # with that, so change it to 'radio_buttons'.
24
+ super . tap do |options |
25
+ options [ :class ] = options [ :class ] . gsub ( "radio" , "radio_buttons" )
45
26
end
46
-
47
- # FROM LAST VERSION OF FB
48
- # bootstrap_vertical_form_input_wrapping do
49
- # legend_html <<
50
- # input_div_wrapping do
51
- # choices_group_wrapping do
52
- # collection.map { |choice|
53
- # choice_wrapping(choice_wrapping_html_options(choice)) do
54
- # choice_html(choice)
55
- # end
56
- # }.join("\n").html_safe
57
- # end
58
- # end
59
- # end
60
- # end
27
+ end
61
28
62
29
# This came from check_boxes. Do needed refactoring.
63
30
def choice_wrapping_html_options ( choice )
64
31
super ( choice ) . tap do |options |
65
32
options [ :class ] = ( ( options [ :class ] . split ) << "radio" ) . join ( " " )
66
- options [ :for ] = choice_input_dom_id ( choice )
67
33
end
68
34
end
69
35
70
- # This came from check_boxes. Do needed refactoring.
71
- def choice_label_html_options ( choice )
72
- choice_wrapping_html_options ( choice )
73
- end
74
-
75
- # From FB1.x
76
- # def choice_html(choice)
77
- # template.content_tag(:label, label_html_options.merge(:for => choice_input_dom_id(choice), :class => nil)) do
78
- # builder.radio_button(input_name, choice_value(choice), input_html_options.merge(choice_html_options(choice)).merge(:required => false)) <<
79
- #
80
- # choice_label(choice)
81
- # end
82
- # end
83
-
84
-
85
- # FROM F2.2
86
36
def choice_html ( choice )
87
37
template . content_tag ( :label ,
88
38
builder . radio_button ( input_name , choice_value ( choice ) , input_html_options . merge ( choice_html_options ( choice ) ) . merge ( :required => false ) ) <<
89
39
choice_label ( choice ) ,
90
- # label_html_options.merge(:for => choice_input_dom_id(choice), :class => nil)
91
40
label_html_options . merge ( choice_label_html_options ( choice ) )
92
41
)
93
42
end
94
43
95
- # Override to remove the for attribute since this isn't associated with any element, as it's
96
- # nested inside the legend.
97
- def label_html_options
98
- super . merge ( :for => nil )
99
- end
100
-
101
-
102
-
103
44
end
104
45
end
105
46
end
0 commit comments