bootstrap_form 4.2.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +13 -0
  3. data/.github/workflows/ruby.yml +46 -0
  4. data/.gitignore +16 -1
  5. data/.rubocop.yml +20 -17
  6. data/CHANGELOG.md +59 -1
  7. data/CONTRIBUTING.md +72 -6
  8. data/Dangerfile +5 -7
  9. data/Dockerfile +26 -0
  10. data/Gemfile +10 -13
  11. data/OLD-README.md +12 -1
  12. data/README.md +140 -60
  13. data/RELEASING.md +2 -2
  14. data/UPGRADE-4.0.md +1 -1
  15. data/UPGRADE-5.0.md +25 -0
  16. data/bootstrap_form.gemspec +9 -5
  17. data/demo/app/assets/config/manifest.js +1 -2
  18. data/demo/app/helpers/bootstrap_helper.rb +5 -5
  19. data/demo/app/views/bootstrap/form.html.erb +14 -1
  20. data/demo/app/views/layouts/application.html.erb +3 -3
  21. data/demo/config/environments/development.rb +1 -1
  22. data/demo/config/puma.rb +2 -2
  23. data/demo/db/schema.rb +2 -2
  24. data/docker-compose.yml +70 -0
  25. data/gemfiles/5.2.gemfile +4 -0
  26. data/gemfiles/6.0.gemfile +4 -0
  27. data/gemfiles/6.1.gemfile +4 -0
  28. data/gemfiles/edge.gemfile +4 -0
  29. data/lib/bootstrap_form/action_view_extensions/form_helper.rb +1 -15
  30. data/lib/bootstrap_form/components/labels.rb +1 -1
  31. data/lib/bootstrap_form/components/layout.rb +1 -1
  32. data/lib/bootstrap_form/components/validation.rb +1 -1
  33. data/lib/bootstrap_form/configuration.rb +22 -0
  34. data/lib/bootstrap_form/form_builder.rb +17 -2
  35. data/lib/bootstrap_form/form_group.rb +21 -10
  36. data/lib/bootstrap_form/form_group_builder.rb +6 -8
  37. data/lib/bootstrap_form/helpers/bootstrap.rb +16 -18
  38. data/lib/bootstrap_form/inputs/base.rb +5 -5
  39. data/lib/bootstrap_form/inputs/check_box.rb +9 -23
  40. data/lib/bootstrap_form/inputs/collection_select.rb +1 -0
  41. data/lib/bootstrap_form/inputs/file_field.rb +3 -15
  42. data/lib/bootstrap_form/inputs/grouped_collection_select.rb +1 -0
  43. data/lib/bootstrap_form/inputs/radio_button.rb +6 -24
  44. data/lib/bootstrap_form/inputs/select.rb +1 -0
  45. data/lib/bootstrap_form/inputs/time_zone_select.rb +1 -0
  46. data/lib/bootstrap_form/version.rb +1 -1
  47. data/lib/bootstrap_form.rb +17 -7
  48. metadata +33 -10
  49. data/.travis.yml +0 -38
@@ -0,0 +1,70 @@
1
+ version: '2.4'
2
+
3
+ services:
4
+ app: &app
5
+ build:
6
+ context: .
7
+ args:
8
+ RUBY_VERSION: '2.7.1'
9
+ NODE_MAJOR: '12'
10
+ YARN_VERSION: '1.22.4'
11
+ BUNDLER_VERSION: '2.1.4'
12
+ image: bootstrap-form:0.0.1
13
+ tmpfs:
14
+ - /tmp
15
+
16
+ backend: &backend
17
+ <<: *app
18
+ stdin_open: true
19
+ tty: true
20
+ volumes:
21
+ - .:/app:cached
22
+ - rails_cache:/app/tmp/cache
23
+ - bundle:/usr/local/bundle
24
+ - node_modules:/app/node_modules
25
+ - packs:/app/public/packs
26
+ environment:
27
+ - NODE_ENV=development
28
+ - RAILS_ENV=${RAILS_ENV:-development}
29
+ - BOOTSNAP_CACHE_DIR=/usr/local/bundle/_bootsnap
30
+ - WEBPACKER_DEV_SERVER_HOST=webpacker
31
+ - WEB_CONCURRENCY=1
32
+ - HISTFILE=/app/.bash_history
33
+ - EDITOR=vi
34
+
35
+ shell:
36
+ <<: *backend
37
+ command: /bin/bash
38
+ ports:
39
+ - '3000:3000'
40
+
41
+ server:
42
+ <<: *backend
43
+ command: sh -c "cd demo/app && bundle exec rails server -b 0.0.0.0"
44
+ ports:
45
+ - '3000:3000'
46
+
47
+ test:
48
+ <<: *backend
49
+ command: rake test
50
+
51
+ webpacker:
52
+ <<: *app
53
+ command: ./bin/webpack-dev-server
54
+ ports:
55
+ - '3035:3035'
56
+ volumes:
57
+ - .:/app:cached
58
+ - bundle:/usr/local/bundle
59
+ - node_modules:/app/node_modules
60
+ - packs:/app/public/packs
61
+ environment:
62
+ - NODE_ENV=${NODE_ENV:-development}
63
+ - RAILS_ENV=${RAILS_ENV:-development}
64
+ - WEBPACKER_DEV_SERVER_HOST=0.0.0.0
65
+
66
+ volumes:
67
+ bundle:
68
+ node_modules:
69
+ rails_cache:
70
+ packs:
@@ -0,0 +1,4 @@
1
+ gems = "#{File.dirname __dir__}/Gemfile"
2
+ eval File.read(gems), binding, gems # rubocop: disable Security/Eval
3
+
4
+ gem "rails", "~> 5.2.0"
@@ -0,0 +1,4 @@
1
+ gems = "#{File.dirname __dir__}/Gemfile"
2
+ eval File.read(gems), binding, gems # rubocop: disable Security/Eval
3
+
4
+ gem "rails", "~> 6.0.0"
@@ -0,0 +1,4 @@
1
+ gems = "#{File.dirname __dir__}/Gemfile"
2
+ eval File.read(gems), binding, gems # rubocop: disable Security/Eval
3
+
4
+ gem "rails", "~> 6.1.0"
@@ -0,0 +1,4 @@
1
+ gems = "#{File.dirname __dir__}/Gemfile"
2
+ eval File.read(gems), binding, gems # rubocop: disable Security/Eval
3
+
4
+ gem "rails", git: "https://github.com/rails/rails.git"
@@ -20,8 +20,6 @@ module BootstrapForm
20
20
  def bootstrap_form_for(record, options={}, &block)
21
21
  options.reverse_merge!(builder: BootstrapForm::FormBuilder)
22
22
 
23
- options = process_options(options)
24
-
25
23
  with_bootstrap_form_field_error_proc do
26
24
  form_for(record, options, &block)
27
25
  end
@@ -30,10 +28,8 @@ module BootstrapForm
30
28
  def bootstrap_form_with(options={}, &block)
31
29
  options.reverse_merge!(builder: BootstrapForm::FormBuilder)
32
30
 
33
- options = process_options(options)
34
-
35
31
  with_bootstrap_form_field_error_proc do
36
- form_with(options, &block)
32
+ form_with(**options, &block)
37
33
  end
38
34
  end
39
35
 
@@ -45,16 +41,6 @@ module BootstrapForm
45
41
 
46
42
  private
47
43
 
48
- def process_options(options)
49
- options[:html] ||= {}
50
- options[:html][:role] ||= "form"
51
-
52
- options[:layout] == :inline &&
53
- options[:html][:class] = [options[:html][:class], "form-inline"].compact.join(" ")
54
-
55
- options
56
- end
57
-
58
44
  def with_bootstrap_form_field_error_proc
59
45
  original_proc = ActionView::Base.field_error_proc
60
46
  ActionView::Base.field_error_proc = BootstrapForm.field_error_proc
@@ -23,7 +23,7 @@ module BootstrapForm
23
23
  end
24
24
 
25
25
  def label_classes(name, options, custom_label_col, group_layout)
26
- classes = [options[:class], label_layout_classes(custom_label_col, group_layout)]
26
+ classes = ["form-label", options[:class], label_layout_classes(custom_label_col, group_layout)]
27
27
 
28
28
  case options.delete(:required)
29
29
  when true
@@ -8,7 +8,7 @@ module BootstrapForm
8
8
  private
9
9
 
10
10
  def layout_default?(field_layout=nil)
11
- [:default, nil].include? layout_in_effect(field_layout)
11
+ layout_in_effect(field_layout) == :default
12
12
  end
13
13
 
14
14
  def layout_horizontal?(field_layout=nil)
@@ -14,7 +14,7 @@ module BootstrapForm
14
14
  def required_attribute?(obj, attribute)
15
15
  return false unless obj && attribute
16
16
 
17
- target = obj.class == Class ? obj : obj.class
17
+ target = obj.instance_of?(Class) ? obj : obj.class
18
18
 
19
19
  target_validators = if target.respond_to? :validators_on
20
20
  target.validators_on(attribute).map(&:class)
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BootstrapForm
4
+ class Configuration
5
+ def default_form_attributes=(attributes)
6
+ case attributes
7
+ when nil
8
+ @default_form_attributes = {}
9
+ when Hash
10
+ @default_form_attributes = attributes
11
+ else
12
+ raise ArgumentError, "Unsupported default_form_attributes #{attributes.inspect}"
13
+ end
14
+ end
15
+
16
+ def default_form_attributes
17
+ return @default_form_attributes if defined? @default_form_attributes
18
+
19
+ {}
20
+ end
21
+ end
22
+ end
@@ -43,10 +43,10 @@ module BootstrapForm
43
43
  include BootstrapForm::Inputs::UrlField
44
44
  include BootstrapForm::Inputs::WeekField
45
45
 
46
- delegate :content_tag, :capture, :concat, to: :@template
46
+ delegate :content_tag, :capture, :concat, :tag, to: :@template
47
47
 
48
48
  def initialize(object_name, object, template, options)
49
- @layout = options[:layout]
49
+ @layout = options[:layout] || default_layout
50
50
  @label_col = options[:label_col] || default_label_col
51
51
  @control_col = options[:control_col] || default_control_col
52
52
  @label_errors = options[:label_errors] || false
@@ -57,9 +57,19 @@ module BootstrapForm
57
57
  options[:inline_errors] != false
58
58
  end
59
59
  @acts_like_form_tag = options[:acts_like_form_tag]
60
+ add_default_form_attributes_and_form_inline options
60
61
  super
61
62
  end
62
63
 
64
+ def add_default_form_attributes_and_form_inline(options)
65
+ options[:html] ||= {}
66
+ options[:html].reverse_merge!(BootstrapForm.config.default_form_attributes)
67
+
68
+ return unless options[:layout] == :inline
69
+
70
+ options[:html][:class] = [options[:html][:class], "col-auto", "g-3"].compact.join(" ")
71
+ end
72
+
63
73
  def fields_for_with_bootstrap(record_name, record_object=nil, fields_options={}, &block)
64
74
  fields_options = fields_for_options(record_object, fields_options)
65
75
  record_object.is_a?(Hash) && record_object.extractable_options? &&
@@ -86,6 +96,11 @@ module BootstrapForm
86
96
  field_options
87
97
  end
88
98
 
99
+ def default_layout
100
+ # :default, :horizontal or :inline
101
+ :default
102
+ end
103
+
89
104
  def default_label_col
90
105
  "col-sm-2"
91
106
  end
@@ -10,9 +10,9 @@ module BootstrapForm
10
10
 
11
11
  options[:class] = form_group_classes(options)
12
12
 
13
- content_tag(:div, options.except(:append, :id, :label, :help, :icon,
14
- :input_group_class, :label_col, :control_col,
15
- :add_control_col_class, :layout, :prepend)) do
13
+ tag.div(**options.except(:append, :id, :label, :help, :icon,
14
+ :input_group_class, :label_col, :control_col,
15
+ :add_control_col_class, :layout, :prepend, :floating)) do
16
16
  form_group_content(
17
17
  generate_label(options[:id], name, options[:label], options[:label_col], options[:layout]),
18
18
  generate_help(name, options[:help]), options, &block
@@ -24,8 +24,8 @@ module BootstrapForm
24
24
 
25
25
  def form_group_content_tag(name, field_name, without_field_name, options, html_options)
26
26
  html_class = control_specific_class(field_name)
27
- html_class = "#{html_class} form-inline" if @layout == :horizontal && options[:skip_inline].blank?
28
- content_tag(:div, class: html_class) do
27
+ html_class = "#{html_class} col-auto g-3" if @layout == :horizontal && options[:skip_inline].blank?
28
+ tag.div(class: html_class) do
29
29
  input_with_error(name) do
30
30
  send(without_field_name, name, options, html_options)
31
31
  end
@@ -34,10 +34,12 @@ module BootstrapForm
34
34
 
35
35
  def form_group_content(label, help_text, options, &block)
36
36
  if group_layout_horizontal?(options[:layout])
37
- concat(label).concat(content_tag(:div, capture(&block) + help_text, class: form_group_control_class(options)))
37
+ concat(label).concat(tag.div(capture(&block) + help_text, class: form_group_control_class(options)))
38
38
  else
39
- concat(label)
39
+ # Floating labels need to be rendered after the field
40
+ concat(label) unless options[:floating]
40
41
  concat(capture(&block))
42
+ concat(label) if options[:floating]
41
43
  concat(help_text) if help_text
42
44
  end
43
45
  end
@@ -50,15 +52,24 @@ module BootstrapForm
50
52
  end
51
53
 
52
54
  def form_group_classes(options)
53
- classes = ["form-group", options[:class].try(:split)].flatten.compact
54
- classes << "row" if group_layout_horizontal?(options[:layout]) && classes.exclude?("form-row")
55
- classes << "form-inline" if field_inline_override?(options[:layout])
55
+ classes = ["mb-3", options[:class].try(:split)].flatten.compact
56
+ classes << "row" if horizontal_group_with_gutters?(options[:layout], classes)
57
+ classes << "col-auto g-3" if field_inline_override?(options[:layout])
56
58
  classes << feedback_class if options[:icon]
59
+ classes << "form-floating" if options[:floating]
57
60
  classes
58
61
  end
59
62
 
63
+ def horizontal_group_with_gutters?(layout, classes)
64
+ group_layout_horizontal?(layout) && !classes_include_gutters?(classes)
65
+ end
66
+
60
67
  def group_layout_horizontal?(layout)
61
68
  get_group_layout(layout) == :horizontal
62
69
  end
70
+
71
+ def classes_include_gutters?(classes)
72
+ classes.any? { |c| c =~ /^g-\d+$/ }
73
+ end
63
74
  end
64
75
  end
@@ -6,7 +6,7 @@ module BootstrapForm
6
6
 
7
7
  private
8
8
 
9
- def form_group_builder(method, options, html_options=nil)
9
+ def form_group_builder(method, options, html_options=nil, &block)
10
10
  no_wrapper = options[:wrapper] == false
11
11
 
12
12
  options = form_group_builder_options(options, method)
@@ -21,16 +21,14 @@ module BootstrapForm
21
21
  if no_wrapper
22
22
  yield
23
23
  else
24
- form_group(method, form_group_options) { yield }
24
+ form_group(method, form_group_options, &block)
25
25
  end
26
26
  end
27
27
 
28
28
  def form_group_builder_options(options, method)
29
29
  options.symbolize_keys!
30
30
  options = convert_form_tag_options(method, options) if acts_like_form_tag
31
- unless options[:skip_label]
32
- options[:required] = form_group_required(options) if options.key?(:skip_required)
33
- end
31
+ options[:required] = form_group_required(options) if !options[:skip_label] && options.key?(:skip_required)
34
32
  options
35
33
  end
36
34
 
@@ -48,7 +46,8 @@ module BootstrapForm
48
46
  id: options[:id], help: options[:help], icon: options[:icon],
49
47
  label_col: options[:label_col], control_col: options[:control_col],
50
48
  add_control_col_class: options[:add_control_col_class],
51
- layout: get_group_layout(options[:layout]), class: options[:wrapper_class]
49
+ layout: get_group_layout(options[:layout]), class: options[:wrapper_class],
50
+ floating: options[:floating]
52
51
  }
53
52
 
54
53
  form_group_options.merge!(wrapper_options) if wrapper_options.is_a?(Hash)
@@ -57,12 +56,11 @@ module BootstrapForm
57
56
  end
58
57
 
59
58
  def form_group_label(options, css_options)
60
- hash = {
59
+ {
61
60
  text: form_group_label_text(options[:label]),
62
61
  class: form_group_label_class(options),
63
62
  required: options[:required]
64
63
  }.merge(css_options[:id].present? ? { for: css_options[:id] } : {})
65
- hash
66
64
  end
67
65
 
68
66
  def form_group_label_text(label)
@@ -14,7 +14,7 @@ module BootstrapForm
14
14
  def primary(name=nil, options={}, &block)
15
15
  setup_css_class "btn btn-primary", options
16
16
 
17
- if options[:render_as_button] || block_given?
17
+ if options[:render_as_button] || block
18
18
  options.except! :render_as_button
19
19
  button(name, options, &block)
20
20
  else
@@ -26,8 +26,8 @@ module BootstrapForm
26
26
  css = options[:class] || "alert alert-danger"
27
27
  return unless object.respond_to?(:errors) && object.errors.full_messages.any?
28
28
 
29
- content_tag :div, class: css do
30
- concat content_tag :p, title
29
+ tag.div class: css do
30
+ concat tag.p title
31
31
  concat error_summary unless options[:error_summary] == false
32
32
  end
33
33
  end
@@ -35,9 +35,9 @@ module BootstrapForm
35
35
  def error_summary
36
36
  return unless object.errors.any?
37
37
 
38
- content_tag :ul, class: "rails-bootstrap-forms-error-summary" do
38
+ tag.ul class: "rails-bootstrap-forms-error-summary" do
39
39
  object.errors.full_messages.each do |error|
40
- concat content_tag(:li, error)
40
+ concat tag.li(error)
41
41
  end
42
42
  end
43
43
  end
@@ -46,8 +46,9 @@ module BootstrapForm
46
46
  return unless error?(name)
47
47
 
48
48
  hide_attribute_name = options[:hide_attribute_name] || false
49
+ custom_class = options[:custom_class] || false
49
50
 
50
- content_tag :div, class: "alert alert-danger" do
51
+ tag.div class: custom_class || "invalid-feedback" do
51
52
  if hide_attribute_name
52
53
  object.errors[name].join(", ")
53
54
  else
@@ -82,10 +83,10 @@ module BootstrapForm
82
83
 
83
84
  input = capture(&block) || ActiveSupport::SafeBuffer.new
84
85
 
85
- input = prepend_input(options) + input + append_input(options)
86
+ input = attach_input(options, :prepend) + input + attach_input(options, :append)
86
87
  input += generate_error(name)
87
88
  options.present? &&
88
- input = content_tag(:div, input, class: ["input-group", options[:input_group_class]].compact)
89
+ input = tag.div(input, class: ["input-group", options[:input_group_class]].compact)
89
90
  input
90
91
  end
91
92
 
@@ -95,9 +96,9 @@ module BootstrapForm
95
96
  end
96
97
 
97
98
  def input_group_content(content)
98
- return content if content =~ /btn/
99
+ return content if /btn/.match?(content)
99
100
 
100
- content_tag(:span, content, class: "input-group-text")
101
+ tag.span(content, class: "input-group-text")
101
102
  end
102
103
 
103
104
  def static_class
@@ -106,14 +107,11 @@ module BootstrapForm
106
107
 
107
108
  private
108
109
 
109
- def append_input(options)
110
- html = content_tag(:div, input_group_content(options[:append]), class: "input-group-append") if options[:append]
111
- html || ActiveSupport::SafeBuffer.new
112
- end
113
-
114
- def prepend_input(options)
115
- html = content_tag(:div, input_group_content(options[:prepend]), class: "input-group-prepend") if options[:prepend]
116
- html || ActiveSupport::SafeBuffer.new
110
+ def attach_input(options, key)
111
+ tags = [*options[key]].map do |item|
112
+ input_group_content(item)
113
+ end
114
+ ActiveSupport::SafeBuffer.new(tags.join)
117
115
  end
118
116
 
119
117
  def setup_css_class(the_class, options={})
@@ -10,7 +10,8 @@ module BootstrapForm
10
10
  define_method "#{field_name}_with_bootstrap" do |name, options={}|
11
11
  form_group_builder(name, options) do
12
12
  prepend_and_append_input(name, options) do
13
- send("#{field_name}_without_bootstrap".to_sym, name, options)
13
+ options[:placeholder] ||= name if options[:floating]
14
+ send("#{field_name}_without_bootstrap".to_sym, name, options.except(:floating))
14
15
  end
15
16
  end
16
17
  end
@@ -19,11 +20,10 @@ module BootstrapForm
19
20
  end
20
21
 
21
22
  def bootstrap_select_group(field_name)
22
- with_field_name = "#{field_name}_with_bootstrap"
23
- without_field_name = "#{field_name}_without_bootstrap"
24
- define_method(with_field_name) do |name, options={}, html_options={}|
23
+ define_method("#{field_name}_with_bootstrap") do |name, options={}, html_options={}|
24
+ html_options = html_options.reverse_merge(control_class: "form-select")
25
25
  form_group_builder(name, options, html_options) do
26
- form_group_content_tag(name, field_name, without_field_name, options, html_options)
26
+ form_group_content_tag(name, field_name, "#{field_name}_without_bootstrap", options, html_options)
27
27
  end
28
28
  end
29
29
 
@@ -10,10 +10,10 @@ module BootstrapForm
10
10
  def check_box_with_bootstrap(name, options={}, checked_value="1", unchecked_value="0", &block)
11
11
  options = options.symbolize_keys!
12
12
  check_box_options = options.except(:class, :label, :label_class, :error_message, :help,
13
- :inline, :custom, :hide_label, :skip_label, :wrapper_class)
13
+ :inline, :hide_label, :skip_label, :wrapper_class, :switch)
14
14
  check_box_options[:class] = check_box_classes(name, options)
15
15
 
16
- content_tag(:div, class: check_box_wrapper_class(options)) do
16
+ tag.div(class: check_box_wrapper_class(options)) do
17
17
  html = check_box_without_bootstrap(name, check_box_options, checked_value, unchecked_value)
18
18
  html.concat(check_box_label(name, options, checked_value, &block)) unless options[:skip_label]
19
19
  html.concat(generate_error(name)) if options[:error_message]
@@ -38,8 +38,8 @@ module BootstrapForm
38
38
  end
39
39
 
40
40
  def check_box_description(name, options, &block)
41
- content = block_given? ? capture(&block) : options[:label]
42
- content || (object && object.class.human_attribute_name(name)) || name.to_s.humanize
41
+ content = block ? capture(&block) : options[:label]
42
+ content || object&.class&.human_attribute_name(name) || name.to_s.humanize
43
43
  end
44
44
 
45
45
  def check_box_value(name, value)
@@ -50,40 +50,26 @@ module BootstrapForm
50
50
  end
51
51
 
52
52
  def check_box_classes(name, options)
53
- classes = [options[:class]]
54
- classes << (options[:custom] ? "custom-control-input" : "form-check-input")
53
+ classes = Array(options[:class]) << "form-check-input"
55
54
  classes << "is-invalid" if error?(name)
56
55
  classes << "position-static" if options[:skip_label] || options[:hide_label]
57
56
  classes.flatten.compact
58
57
  end
59
58
 
60
59
  def check_box_label_class(options)
61
- classes = []
62
- classes << (options[:custom] ? "custom-control-label" : "form-check-label")
60
+ classes = ["form-check-label"]
63
61
  classes << options[:label_class]
64
62
  classes << hide_class if options[:hide_label]
65
63
  classes.flatten.compact
66
64
  end
67
65
 
68
66
  def check_box_wrapper_class(options)
69
- classes = []
70
- if options[:custom]
71
- classes << custom_check_box_wrapper_class(options)
72
- else
73
- classes << "form-check"
74
- classes << "form-check-inline" if layout_inline?(options[:inline])
75
- end
67
+ classes = ["form-check"]
68
+ classes << "form-check-inline" if layout_inline?(options[:inline])
69
+ classes << "form-switch" if options[:switch]
76
70
  classes << options[:wrapper_class] if options[:wrapper_class].present?
77
71
  classes.flatten.compact
78
72
  end
79
-
80
- def custom_check_box_wrapper_class(options)
81
- classes = []
82
- classes << "custom-control"
83
- classes << (options[:custom] == :switch ? "custom-switch" : "custom-checkbox")
84
- classes << "custom-control-inline" if layout_inline?(options[:inline])
85
- classes
86
- end
87
73
  end
88
74
  end
89
75
  end
@@ -10,6 +10,7 @@ module BootstrapForm
10
10
  # Disabling Metrics/ParameterLists because the upstream Rails method has the same parameters
11
11
  # rubocop:disable Metrics/ParameterLists
12
12
  def collection_select_with_bootstrap(method, collection, value_method, text_method, options={}, html_options={})
13
+ html_options = html_options.reverse_merge(control_class: "form-select")
13
14
  form_group_builder(method, options, html_options) do
14
15
  input_with_error(method) do
15
16
  collection_select_without_bootstrap(method, collection, value_method, text_method, options, html_options)
@@ -8,28 +8,16 @@ module BootstrapForm
8
8
 
9
9
  included do
10
10
  def file_field_with_bootstrap(name, options={})
11
- options = options.reverse_merge(control_class: "custom-file-input")
11
+ options = options.reverse_merge(control_class: "form-control")
12
12
  form_group_builder(name, options) do
13
- content_tag(:div, class: "custom-file") do
14
- input_with_error(name) do
15
- file_field_input(name, options)
16
- end
13
+ input_with_error(name) do
14
+ file_field_without_bootstrap(name, options)
17
15
  end
18
16
  end
19
17
  end
20
18
 
21
19
  bootstrap_alias :file_field
22
20
  end
23
-
24
- private
25
-
26
- def file_field_input(name, options)
27
- placeholder = options.delete(:placeholder) || "Choose file"
28
- placeholder_opts = { class: "custom-file-label" }
29
- placeholder_opts[:for] = options[:id] if options[:id].present?
30
-
31
- file_field_without_bootstrap(name, options) + label(name, placeholder, placeholder_opts)
32
- end
33
21
  end
34
22
  end
35
23
  end
@@ -12,6 +12,7 @@ module BootstrapForm
12
12
  def grouped_collection_select_with_bootstrap(method, collection, group_method,
13
13
  group_label_method, option_key_method,
14
14
  option_value_method, options={}, html_options={})
15
+ html_options = html_options.reverse_merge(control_class: "form-select")
15
16
  form_group_builder(method, options, html_options) do
16
17
  input_with_error(method) do
17
18
  grouped_collection_select_without_bootstrap(method, collection, group_method,
@@ -10,11 +10,11 @@ module BootstrapForm
10
10
  def radio_button_with_bootstrap(name, value, *args)
11
11
  options = args.extract_options!.symbolize_keys!
12
12
  radio_button_options = options.except(:class, :label, :label_class, :error_message, :help,
13
- :inline, :custom, :hide_label, :skip_label, :wrapper_class)
13
+ :inline, :hide_label, :skip_label, :wrapper_class)
14
14
 
15
15
  radio_button_options[:class] = radio_button_classes(name, options)
16
16
 
17
- content_tag(:div, class: radio_button_wrapper_class(options)) do
17
+ tag.div(class: radio_button_wrapper_class(options)) do
18
18
  html = radio_button_without_bootstrap(name, value, radio_button_options)
19
19
  html.concat(radio_button_label(name, value, options)) unless options[:skip_label]
20
20
  html.concat(generate_error(name)) if options[:error_message]
@@ -34,43 +34,25 @@ module BootstrapForm
34
34
  end
35
35
 
36
36
  def radio_button_classes(name, options)
37
- classes = [options[:class]]
38
- classes << (options[:custom] ? "custom-control-input" : "form-check-input")
37
+ classes = Array(options[:class]) << "form-check-input"
39
38
  classes << "is-invalid" if error?(name)
40
39
  classes << "position-static" if options[:skip_label] || options[:hide_label]
41
40
  classes.flatten.compact
42
41
  end
43
42
 
44
43
  def radio_button_label_class(options)
45
- classes = []
46
- classes << (options[:custom] ? "custom-control-label" : "form-check-label")
44
+ classes = ["form-check-label"]
47
45
  classes << options[:label_class]
48
46
  classes << hide_class if options[:hide_label]
49
47
  classes.flatten.compact
50
48
  end
51
49
 
52
50
  def radio_button_wrapper_class(options)
53
- classes = []
54
- classes << if options[:custom]
55
- custom_radio_button_wrapper_class(options)
56
- else
57
- standard_radio_button_wrapper_class(options)
58
- end
59
- classes << options[:wrapper_class] if options[:wrapper_class].present?
60
- classes.flatten.compact
61
- end
62
-
63
- def standard_radio_button_wrapper_class(options)
64
51
  classes = ["form-check"]
65
52
  classes << "form-check-inline" if layout_inline?(options[:inline])
66
53
  classes << "disabled" if options[:disabled]
67
- classes
68
- end
69
-
70
- def custom_radio_button_wrapper_class(options)
71
- classes = ["custom-control", "custom-radio"]
72
- classes << "custom-control-inline" if layout_inline?(options[:inline])
73
- classes
54
+ classes << options[:wrapper_class] if options[:wrapper_class].present?
55
+ classes.flatten.compact
74
56
  end
75
57
  end
76
58
  end
@@ -8,6 +8,7 @@ module BootstrapForm
8
8
 
9
9
  included do
10
10
  def select_with_bootstrap(method, choices=nil, options={}, html_options={}, &block)
11
+ html_options = html_options.reverse_merge(control_class: "form-select")
11
12
  form_group_builder(method, options, html_options) do
12
13
  prepend_and_append_input(method, options) do
13
14
  select_without_bootstrap(method, choices, options, html_options, &block)
@@ -8,6 +8,7 @@ module BootstrapForm
8
8
 
9
9
  included do
10
10
  def time_zone_select_with_bootstrap(method, priority_zones=nil, options={}, html_options={})
11
+ html_options = html_options.reverse_merge(control_class: "form-select")
11
12
  form_group_builder(method, options, html_options) do
12
13
  input_with_error(method) do
13
14
  time_zone_select_without_bootstrap(method, priority_zones, options, html_options)