formtastic-bootstrap 1.2.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/Gemfile +5 -3
  2. data/Gemfile.lock +72 -60
  3. data/README.md +4 -1
  4. data/Rakefile +1 -1
  5. data/VERSION +1 -1
  6. data/formtastic-bootstrap.gemspec +49 -16
  7. data/lib/formtastic-bootstrap/actions/base.rb +22 -0
  8. data/lib/formtastic-bootstrap/actions/button_action.rb +13 -0
  9. data/lib/formtastic-bootstrap/actions/input_action.rb +13 -0
  10. data/lib/formtastic-bootstrap/actions/link_action.rb +12 -0
  11. data/lib/formtastic-bootstrap/actions.rb +10 -0
  12. data/lib/formtastic-bootstrap/form_builder.rb +4 -2
  13. data/lib/formtastic-bootstrap/helpers/action_helper.rb +12 -0
  14. data/lib/formtastic-bootstrap/helpers/actions_helper.rb +24 -0
  15. data/lib/formtastic-bootstrap/helpers/fieldset_wrapper.rb +2 -4
  16. data/lib/formtastic-bootstrap/helpers/inputs_helper.rb +0 -2
  17. data/lib/formtastic-bootstrap/helpers.rb +6 -8
  18. data/lib/formtastic-bootstrap/inputs/base/choices.rb +6 -35
  19. data/lib/formtastic-bootstrap/inputs/base/collections.rb +9 -0
  20. data/lib/formtastic-bootstrap/inputs/base/grouped_collections.rb +9 -0
  21. data/lib/formtastic-bootstrap/inputs/base/hints.rb +1 -1
  22. data/lib/formtastic-bootstrap/inputs/base/labelling.rb +14 -3
  23. data/lib/formtastic-bootstrap/inputs/base/numeric.rb +9 -0
  24. data/lib/formtastic-bootstrap/inputs/base/stringish.rb +4 -5
  25. data/lib/formtastic-bootstrap/inputs/base/timeish.rb +38 -18
  26. data/lib/formtastic-bootstrap/inputs/base/wrapping.rb +22 -34
  27. data/lib/formtastic-bootstrap/inputs/base.rb +29 -6
  28. data/lib/formtastic-bootstrap/inputs/boolean_input.rb +14 -18
  29. data/lib/formtastic-bootstrap/inputs/check_boxes_input.rb +16 -11
  30. data/lib/formtastic-bootstrap/inputs/date_input.rb +3 -9
  31. data/lib/formtastic-bootstrap/inputs/date_select_input.rb +8 -0
  32. data/lib/formtastic-bootstrap/inputs/datetime_input.rb +3 -12
  33. data/lib/formtastic-bootstrap/inputs/datetime_select_input.rb +8 -0
  34. data/lib/formtastic-bootstrap/inputs/email_input.rb +1 -1
  35. data/lib/formtastic-bootstrap/inputs/file_input.rb +1 -1
  36. data/lib/formtastic-bootstrap/inputs/hidden_input.rb +1 -1
  37. data/lib/formtastic-bootstrap/inputs/number_input.rb +3 -3
  38. data/lib/formtastic-bootstrap/inputs/password_input.rb +1 -1
  39. data/lib/formtastic-bootstrap/inputs/phone_input.rb +1 -1
  40. data/lib/formtastic-bootstrap/inputs/radio_input.rb +28 -14
  41. data/lib/formtastic-bootstrap/inputs/range_input.rb +1 -1
  42. data/lib/formtastic-bootstrap/inputs/search_input.rb +1 -1
  43. data/lib/formtastic-bootstrap/inputs/select_input.rb +3 -1
  44. data/lib/formtastic-bootstrap/inputs/string_input.rb +0 -7
  45. data/lib/formtastic-bootstrap/inputs/text_input.rb +1 -1
  46. data/lib/formtastic-bootstrap/inputs/time_input.rb +3 -9
  47. data/lib/formtastic-bootstrap/inputs/time_select_input.rb +8 -0
  48. data/lib/formtastic-bootstrap/inputs/time_zone_input.rb +1 -1
  49. data/lib/formtastic-bootstrap/inputs/url_input.rb +1 -1
  50. data/lib/formtastic-bootstrap/inputs.rb +30 -23
  51. data/lib/formtastic-bootstrap.rb +16 -1
  52. data/spec/actions/button_action_spec.rb +63 -0
  53. data/spec/actions/input_action_spec.rb +59 -0
  54. data/spec/actions/link_action_spec.rb +92 -0
  55. data/spec/helpers/action_helper_spec.rb +368 -0
  56. data/spec/helpers/actions_helper_spec.rb +147 -0
  57. data/spec/helpers/input_helper_spec.rb +238 -259
  58. data/spec/helpers/inputs_helper_spec.rb +84 -25
  59. data/spec/inputs/boolean_input_spec.rb +108 -75
  60. data/spec/inputs/check_boxes_input_spec.rb +106 -91
  61. data/spec/inputs/date_select_input_spec.rb +164 -0
  62. data/spec/inputs/datetime_select_input_spec.rb +112 -0
  63. data/spec/inputs/deprecated_time_date_datetime_inputs_spec.rb +48 -0
  64. data/spec/inputs/email_input_spec.rb +30 -3
  65. data/spec/inputs/file_input_spec.rb +31 -4
  66. data/spec/inputs/hidden_input_spec.rb +63 -32
  67. data/spec/inputs/number_input_spec.rb +37 -8
  68. data/spec/inputs/password_input_spec.rb +30 -3
  69. data/spec/inputs/phone_input_spec.rb +30 -3
  70. data/spec/inputs/radio_input_spec.rb +87 -60
  71. data/spec/inputs/range_input_spec.rb +32 -5
  72. data/spec/inputs/search_input_spec.rb +29 -3
  73. data/spec/inputs/select_input_spec.rb +164 -107
  74. data/spec/inputs/string_input_spec.rb +33 -22
  75. data/spec/inputs/text_input_spec.rb +39 -14
  76. data/spec/inputs/time_select_input_spec.rb +191 -0
  77. data/spec/inputs/time_zone_input_spec.rb +17 -19
  78. data/spec/inputs/url_input_spec.rb +30 -3
  79. data/spec/spec_helper.rb +21 -15
  80. data/spec/support/custom_macros.rb +61 -228
  81. data/spec/support/fb_custom_macros.rb +23 -0
  82. metadata +109 -28
  83. data/lib/formtastic-bootstrap/helpers/buttons_helper.rb +0 -52
  84. data/spec/builder/errors_spec.rb +0 -214
  85. data/spec/helpers/buttons_helper_spec.rb +0 -149
  86. data/spec/inputs/date_input_spec.rb +0 -147
  87. data/spec/inputs/datetime_input_spec.rb +0 -101
  88. data/spec/inputs/time_input_spec.rb +0 -206
  89. data/spec/support/depracation.rb +0 -6
  90. data/spec/support/formtastic_spec_helper.rb +0 -382
@@ -5,7 +5,7 @@ module FormtasticBootstrap
5
5
 
6
6
  include Formtastic::Inputs::Base::Hints
7
7
 
8
- def hint_html(inline_or_block = :inline)
8
+ def hint_html(inline_or_block = :block)
9
9
  if hint?
10
10
  hint_class = if inline_or_block == :inline
11
11
  options[:hint_class] || builder.default_inline_hint_class
@@ -6,12 +6,23 @@ module FormtasticBootstrap
6
6
  include Formtastic::Inputs::Base::Labelling
7
7
 
8
8
  def label_html_options
9
- {}.tap do |opts|
10
- opts[:for] ||= input_html_options[:id]
11
- opts[:class] = [opts[:class]]
9
+ super.tap do |options|
10
+ # Bootstrap defines class 'label'
11
+ options[:class] = options[:class].reject { |c| c == 'label' }
12
+ # options[:class] << "control-label"
12
13
  end
13
14
  end
14
15
 
16
+ def control_label_html_options
17
+ label_html_options.tap do |options|
18
+ options[:class] << "control-label"
19
+ end
20
+ end
21
+
22
+ def control_label_html
23
+ render_label? ? builder.label(input_name, label_text, control_label_html_options) : "".html_safe
24
+ end
25
+
15
26
  end
16
27
  end
17
28
  end
@@ -0,0 +1,9 @@
1
+ module FormtasticBootstrap
2
+ module Inputs
3
+ module Base
4
+ module Numeric
5
+ include Formtastic::Inputs::Base::Numeric
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,3 @@
1
- # Alas, I need to duplicate code from Formtastic::Inputs::Base::Stringish because
2
- # there's no way to re-import that module.
3
1
  module FormtasticBootstrap
4
2
  module Inputs
5
3
  module Base
@@ -7,9 +5,10 @@ module FormtasticBootstrap
7
5
 
8
6
  include Formtastic::Inputs::Base::Stringish
9
7
 
10
- def wrapper_html_options
11
- new_class = [super[:class], "stringish"].compact.join(" ")
12
- super.merge(:class => new_class)
8
+ def to_html
9
+ bootstrap_wrapping do
10
+ builder.text_field(method, input_html_options)
11
+ end
13
12
  end
14
13
 
15
14
  end
@@ -3,32 +3,52 @@ module FormtasticBootstrap
3
3
  module Base
4
4
  module Timeish
5
5
 
6
- def label_html
7
- # TODO Supress the "for" field?
8
- template.content_tag(:label, label_html_options) do
9
- render_label? ? label_text : "".html_safe
6
+ def to_html
7
+ control_group_wrapping do
8
+ control_label_html <<
9
+ controls_wrapping do
10
+ hidden_fragments <<
11
+ fragments.map do |fragment|
12
+ fragment_input_html(fragment)
13
+ end.join.html_safe
14
+ end
10
15
  end
11
16
  end
12
17
 
13
- def date_input_html
14
- fragment_input_html(:date, "small")
18
+ def controls_wrapper_html_options
19
+ super.tap do |options|
20
+ options[:class] = (options[:class].split << "controls-row").join(" ")
21
+ end
15
22
  end
16
23
 
17
- def time_input_html
18
- fragment_input_html(:time, "mini")
24
+ def fragment_input_html(fragment)
25
+ opts = input_options.merge(:prefix => fragment_prefix, :field_name => fragment_name(fragment), :default => value, :include_blank => include_blank?)
26
+ template.send(:"select_#{fragment}", value, opts, fragment_input_html_options(fragment))
19
27
  end
20
-
21
- def fragment_id(fragment)
22
- # TODO is this right?
23
- # "#{input_html_options[:id]}_#{position(fragment)}i"
24
- "#{input_html_options[:id]}[#{fragment}]"
28
+
29
+ def fragment_input_html_options(fragment)
30
+ input_html_options.tap do |options|
31
+ options[:id] = fragment_id(fragment)
32
+ options[:class] = ((options[:class] || "").split << fragment_class(fragment)).join(" ")
33
+ options[:placeholder] = fragment_placeholder(fragment)
34
+ end
25
35
  end
26
-
27
- def fragment_input_html(fragment, klass)
28
- opts = input_options.merge(:prefix => object_name, :field_name => fragment_name(fragment), :default => value, :include_blank => include_blank?)
29
- template.send(:"text_field_#{fragment}", value, opts, input_html_options.merge(:id => fragment_id(fragment), :class => klass))
36
+
37
+ def fragment_class(fragment)
38
+ {
39
+ :year => "span1",
40
+ :month => "span2",
41
+ :day => "span1",
42
+ :hour => "span1",
43
+ :minute => "span1",
44
+ :second => "span1"
45
+ }[fragment]
30
46
  end
31
-
47
+
48
+ def fragment_placeholder(fragment)
49
+ "." + fragment_class(fragment)
50
+ end
51
+
32
52
  end
33
53
  end
34
54
  end
@@ -5,57 +5,45 @@ module FormtasticBootstrap
5
5
 
6
6
  include Formtastic::Inputs::Base::Wrapping
7
7
 
8
- def generic_input_wrapping(&block)
9
- clearfix_div_wrapping do
10
- label_html <<
11
- input_div_wrapping do
8
+ def bootstrap_wrapping(&block)
9
+ control_group_wrapping do
10
+ control_label_html <<
11
+ controls_wrapping do
12
12
  if options[:prepend]
13
13
  prepended_input_wrapping do
14
- [template.content_tag(:span, options[:prepend], :class => 'add-on'), yield].join("\n").html_safe
14
+ [template.content_tag(:span, options[:prepend], :class => 'add-on'), yield, hint_html].join("\n").html_safe
15
15
  end
16
16
  else
17
- yield
17
+ [yield, hint_html].join("\n").html_safe
18
18
  end
19
19
  end
20
20
  end
21
21
  end
22
22
 
23
- def clearfix_div_wrapping(&block)
24
- template.content_tag(:div, wrapper_html_options) do
25
- yield
26
- end
23
+ def control_group_wrapping(&block)
24
+ template.content_tag(:div,
25
+ [template.capture(&block), error_html].join("\n").html_safe,
26
+ wrapper_html_options
27
+ )
27
28
  end
28
29
 
29
- def input_div_wrapping(inline_or_block_errors = :inline)
30
- template.content_tag(:div, :class => "input") do
31
- [yield, error_html(inline_or_block_errors), hint_html(inline_or_block_errors)].join("\n").html_safe
32
- end
30
+ def controls_wrapping(&block)
31
+ template.content_tag(:div, template.capture(&block).html_safe, controls_wrapper_html_options)
33
32
  end
34
-
35
- def inline_inputs_div_wrapping(&block)
36
- template.content_tag(:div, :class => "inline-inputs") do
37
- yield
38
- end
33
+
34
+ def controls_wrapper_html_options
35
+ {
36
+ :class => "controls"
37
+ }
39
38
  end
40
39
 
41
40
  def wrapper_html_options
42
- opts = options[:wrapper_html] || {}
43
- opts[:class] ||= []
44
- opts[:class] = [opts[:class].to_s] unless opts[:class].is_a?(Array)
45
- opts[:class] << as
46
- opts[:class] << "clearfix"
47
- # opts[:class] << "input"
48
- opts[:class] << "error" if errors?
49
- opts[:class] << "optional" if optional?
50
- opts[:class] << "required" if required?
51
- opts[:class] << "autofocus" if autofocus?
52
- opts[:class] = opts[:class].join(' ')
53
-
54
- opts[:id] ||= wrapper_dom_id
55
-
56
- opts
41
+ super.tap do |options|
42
+ options[:class] << " control-group"
43
+ end
57
44
  end
58
45
 
46
+ # Bootstrap prepend feature
59
47
  def prepended_input_wrapping(&block)
60
48
  template.content_tag(:div, :class => 'input-prepend') do
61
49
  yield
@@ -1,22 +1,45 @@
1
- require "formtastic-bootstrap/inputs/base/choices"
2
1
  require "formtastic-bootstrap/inputs/base/errors"
3
2
  require "formtastic-bootstrap/inputs/base/hints"
4
3
  require "formtastic-bootstrap/inputs/base/html"
5
4
  require "formtastic-bootstrap/inputs/base/labelling"
6
- require "formtastic-bootstrap/inputs/base/stringish"
7
- require "formtastic-bootstrap/inputs/base/timeish"
8
- require "formtastic-bootstrap/inputs/base/wrapping"
9
5
 
10
6
  module FormtasticBootstrap
11
7
  module Inputs
12
8
  module Base
13
9
 
10
+ # autoload :DatetimePickerish
11
+ # autoload :Associations
12
+ autoload :Collections, "formtastic-bootstrap/inputs/base/collections"
13
+ autoload :Choices, "formtastic-bootstrap/inputs/base/choices"
14
+ # autoload :Database
15
+ # autoload :Errors
16
+ # autoload :Fileish
17
+ autoload :GroupedCollections, "formtastic-bootstrap/inputs/base/grouped_collections"
18
+ # autoload :Hints
19
+ # autoload :Html
20
+ # autoload :Labelling
21
+ # autoload :Naming
22
+ autoload :Numeric, "formtastic-bootstrap/inputs/base/numeric"
23
+ # autoload :Options
24
+ # autoload :Placeholder
25
+ autoload :Stringish, "formtastic-bootstrap/inputs/base/stringish"
26
+ autoload :Timeish, "formtastic-bootstrap/inputs/base/timeish"
27
+ # autoload :Validations
28
+ autoload :Wrapping, "formtastic-bootstrap/inputs/base/wrapping"
29
+
30
+ include Html
31
+ # include Options
32
+ # include Database
33
+ # include Database
14
34
  include Errors
15
35
  include Hints
16
- include Html
36
+ # include Naming
37
+ # include Validations
38
+ # include Fileish
39
+ # include Associations
17
40
  include Labelling
18
41
  include Wrapping
19
-
42
+
20
43
  end
21
44
  end
22
45
  end
@@ -2,30 +2,26 @@
2
2
  module FormtasticBootstrap
3
3
  module Inputs
4
4
  class BooleanInput < Formtastic::Inputs::BooleanInput
5
- include Base
6
-
5
+ include Base
6
+
7
7
  def to_html
8
- clearfix_div_wrapping do
9
- empty_label <<
8
+ control_group_wrapping do
9
+ control_label_html <<
10
10
  hidden_field_html <<
11
- input_div_wrapping(:block) do
12
- template.content_tag(:ul, :class => "inputs-list") do
13
- template.content_tag(:li) do
14
- label_with_nested_checkbox
15
- end
16
- end
11
+ controls_wrapping do
12
+ label_with_nested_checkbox
17
13
  end
18
14
  end
19
15
  end
20
16
 
21
- def label_text_with_embedded_checkbox
22
- # That newline matters! Why, I do no not know.
23
- check_box_html << "\n" << template.content_tag(:span) do label_text end
24
- end
25
-
26
- # Need this for formatting to work.
27
- def empty_label
28
- template.content_tag(:label) do end
17
+ def label_with_nested_checkbox
18
+ builder.label(
19
+ method,
20
+ label_text_with_embedded_checkbox,
21
+ label_html_options.tap do |options|
22
+ options[:class] << "checkbox"
23
+ end
24
+ )
29
25
  end
30
26
 
31
27
  end
@@ -4,29 +4,34 @@ module FormtasticBootstrap
4
4
  include Base
5
5
  include Base::Choices
6
6
 
7
+ # TODO Make sure help blocks work correctly.
8
+ # TODO Support .inline
9
+
7
10
  def to_html
8
- clearfix_div_wrapping do
9
- legend_html <<
11
+ control_group_wrapping do
12
+ control_label_html <<
10
13
  hidden_field_for_all <<
11
- input_div_wrapping do
12
- choices_group_wrapping do
13
- collection.map { |choice|
14
- choice_wrapping(choice_wrapping_html_options(choice)) do
15
- choice_html(choice)
16
- end
17
- }.join("\n").html_safe
18
- end
14
+ controls_wrapping do
15
+ collection.map { |choice|
16
+ choice_html(choice)
17
+ }.join("\n").html_safe
19
18
  end
20
19
  end
21
20
  end
22
21
 
22
+ def choice_wrapping_html_options(choice)
23
+ super(choice).tap do |options|
24
+ options[:class] = ((options[:class].split) << "checkbox").join(" ")
25
+ end
26
+ end
27
+
23
28
  def choice_html(choice)
24
29
  template.content_tag(:label,
25
30
  hidden_fields? ?
26
31
  check_box_with_hidden_input(choice) :
27
32
  check_box_without_hidden_input(choice) <<
28
33
  choice_label(choice),
29
- label_html_options.merge(:for => choice_input_dom_id(choice), :class => nil)
34
+ label_html_options.merge(choice_label_html_options(choice))
30
35
  )
31
36
  end
32
37
 
@@ -1,16 +1,10 @@
1
1
  module FormtasticBootstrap
2
2
  module Inputs
3
- class DateInput < Formtastic::Inputs::DateInput
4
- include Base
5
- include Base::Stringish
6
- include Base::Timeish
7
-
3
+ class DateInput < FormtasticBootstrap::Inputs::DateSelectInput
8
4
  def to_html
9
- generic_input_wrapping do
10
- date_input_html
11
- end
5
+ ::ActiveSupport::Deprecation.warn("DateInput (:as => :date) has been renamed to DateSelectInput (:as => :date_select) and will be removed or changed in the next version of Formtastic, please update your forms.", caller(2))
6
+ super
12
7
  end
13
-
14
8
  end
15
9
  end
16
10
  end
@@ -0,0 +1,8 @@
1
+ module FormtasticBootstrap
2
+ module Inputs
3
+ class DateSelectInput < Formtastic::Inputs::DateSelectInput
4
+ include Base
5
+ include Base::Timeish
6
+ end
7
+ end
8
+ end
@@ -1,19 +1,10 @@
1
1
  module FormtasticBootstrap
2
2
  module Inputs
3
- class DatetimeInput < Formtastic::Inputs::DatetimeInput
4
- include Base
5
- include Base::Stringish
6
- include Base::Timeish
7
-
3
+ class DatetimeInput < FormtasticBootstrap::Inputs::DatetimeSelectInput
8
4
  def to_html
9
- generic_input_wrapping do
10
- inline_inputs_div_wrapping do
11
- # This newline matters.
12
- date_input_html << "\n".html_safe << time_input_html
13
- end
14
- end
5
+ ::ActiveSupport::Deprecation.warn("DatetimeInput (:as => :datetime) has been renamed to DatetimeSelectInput (:as => :datetime_select) and will be removed or changed in the next version of Formtastic, please update your forms.", caller(2))
6
+ super
15
7
  end
16
-
17
8
  end
18
9
  end
19
10
  end
@@ -0,0 +1,8 @@
1
+ module FormtasticBootstrap
2
+ module Inputs
3
+ class DatetimeSelectInput < Formtastic::Inputs::DatetimeSelectInput
4
+ include Base
5
+ include Base::Timeish
6
+ end
7
+ end
8
+ end
@@ -5,7 +5,7 @@ module FormtasticBootstrap
5
5
  include Base::Stringish
6
6
 
7
7
  def to_html
8
- generic_input_wrapping do
8
+ bootstrap_wrapping do
9
9
  builder.email_field(method, input_html_options)
10
10
  end
11
11
  end
@@ -4,7 +4,7 @@ module FormtasticBootstrap
4
4
  include Base
5
5
 
6
6
  def to_html
7
- generic_input_wrapping do
7
+ bootstrap_wrapping do
8
8
  builder.file_field(method, input_html_options)
9
9
  end
10
10
  end
@@ -3,7 +3,7 @@ module FormtasticBootstrap
3
3
  class HiddenInput < Formtastic::Inputs::HiddenInput
4
4
  include Base
5
5
  def to_html
6
- generic_input_wrapping do
6
+ bootstrap_wrapping do
7
7
  builder.hidden_field(method, input_html_options)
8
8
  end
9
9
  end
@@ -2,14 +2,14 @@ module FormtasticBootstrap
2
2
  module Inputs
3
3
  class NumberInput < Formtastic::Inputs::NumberInput
4
4
  include Base
5
- include Base::Stringish
5
+ include Base::Numeric
6
6
 
7
7
  def to_html
8
- generic_input_wrapping do
8
+ bootstrap_wrapping do
9
9
  builder.number_field(method, input_html_options)
10
10
  end
11
11
  end
12
-
12
+
13
13
  end
14
14
  end
15
15
  end
@@ -5,7 +5,7 @@ module FormtasticBootstrap
5
5
  include Base::Stringish
6
6
 
7
7
  def to_html
8
- generic_input_wrapping do
8
+ bootstrap_wrapping do
9
9
  builder.password_field(method, input_html_options)
10
10
  end
11
11
  end
@@ -5,7 +5,7 @@ module FormtasticBootstrap
5
5
  include Base::Stringish
6
6
 
7
7
  def to_html
8
- generic_input_wrapping do
8
+ bootstrap_wrapping do
9
9
  builder.phone_field(method, input_html_options)
10
10
  end
11
11
  end
@@ -4,29 +4,43 @@ module FormtasticBootstrap
4
4
  include Base
5
5
  include Base::Choices
6
6
 
7
+ # TODO Make sure help blocks work correctly.
8
+ # TODO Support .inline
9
+
7
10
  def to_html
8
- clearfix_div_wrapping do
9
- legend_html <<
10
- input_div_wrapping do
11
- choices_group_wrapping do
12
- collection.map { |choice|
13
- choice_wrapping(choice_wrapping_html_options(choice)) do
14
- choice_html(choice)
15
- end
16
- }.join("\n").html_safe
17
- end
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
18
17
  end
19
18
  end
20
19
  end
21
20
 
22
- def choice_html(choice)
23
- template.content_tag(:label, label_html_options.merge(:for => choice_input_dom_id(choice), :class => nil)) do
24
- builder.radio_button(input_name, choice_value(choice), input_html_options.merge(choice_html_options(choice)).merge(:required => false)) <<
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")
26
+ end
27
+ end
25
28
 
26
- choice_label(choice)
29
+ # This came from check_boxes. Do needed refactoring.
30
+ def choice_wrapping_html_options(choice)
31
+ super(choice).tap do |options|
32
+ options[:class] = ((options[:class].split) << "radio").join(" ")
27
33
  end
28
34
  end
29
35
 
36
+ def choice_html(choice)
37
+ template.content_tag(:label,
38
+ builder.radio_button(input_name, choice_value(choice), input_html_options.merge(choice_html_options(choice)).merge(:required => false)) <<
39
+ choice_label(choice),
40
+ label_html_options.merge(choice_label_html_options(choice))
41
+ )
42
+ end
43
+
30
44
  end
31
45
  end
32
46
  end
@@ -5,7 +5,7 @@ module FormtasticBootstrap
5
5
  include Base::Stringish
6
6
 
7
7
  def to_html
8
- generic_input_wrapping do
8
+ bootstrap_wrapping do
9
9
  builder.range_field(method, input_html_options)
10
10
  end
11
11
  end
@@ -5,7 +5,7 @@ module FormtasticBootstrap
5
5
  include Base::Stringish
6
6
 
7
7
  def to_html
8
- generic_input_wrapping do
8
+ bootstrap_wrapping do
9
9
  builder.search_field(method, input_html_options)
10
10
  end
11
11
  end
@@ -2,9 +2,11 @@ module FormtasticBootstrap
2
2
  module Inputs
3
3
  class SelectInput < Formtastic::Inputs::SelectInput
4
4
  include Base
5
+ include Base::Collections
6
+ include Base::GroupedCollections
5
7
 
6
8
  def to_html
7
- generic_input_wrapping do
9
+ bootstrap_wrapping do
8
10
  options[:group_by] ? grouped_select_html : select_html
9
11
  end
10
12
  end
@@ -3,13 +3,6 @@ module FormtasticBootstrap
3
3
  class StringInput < Formtastic::Inputs::StringInput
4
4
  include Base
5
5
  include Base::Stringish
6
-
7
- def to_html
8
- generic_input_wrapping do
9
- builder.text_field(method, input_html_options)
10
- end
11
- end
12
-
13
6
  end
14
7
  end
15
8
  end
@@ -4,7 +4,7 @@ module FormtasticBootstrap
4
4
  include Base
5
5
 
6
6
  def to_html
7
- generic_input_wrapping do
7
+ bootstrap_wrapping do
8
8
  builder.text_area(method, input_html_options)
9
9
  end
10
10
  end
@@ -1,16 +1,10 @@
1
1
  module FormtasticBootstrap
2
2
  module Inputs
3
- class TimeInput < Formtastic::Inputs::TimeInput
4
- include Base
5
- include Base::Stringish
6
- include Base::Timeish
7
-
3
+ class TimeInput < FormtasticBootstrap::Inputs::TimeSelectInput
8
4
  def to_html
9
- generic_input_wrapping do
10
- time_input_html
11
- end
5
+ ::ActiveSupport::Deprecation.warn("TimeInput (:as => :time) has been renamed to TimeSelectInput (:as => :time_select) and will be removed or changed in the next version of Formtastic, please update your forms.", caller(2))
6
+ super
12
7
  end
13
-
14
8
  end
15
9
  end
16
10
  end
@@ -0,0 +1,8 @@
1
+ module FormtasticBootstrap
2
+ module Inputs
3
+ class TimeSelectInput < Formtastic::Inputs::TimeSelectInput
4
+ include Base
5
+ include Base::Timeish
6
+ end
7
+ end
8
+ end
@@ -4,7 +4,7 @@ module FormtasticBootstrap
4
4
  include Base
5
5
 
6
6
  def to_html
7
- generic_input_wrapping do
7
+ bootstrap_wrapping do
8
8
  builder.time_zone_select(method, priority_zones, input_options, input_html_options)
9
9
  end
10
10
  end