rails_bootstrap_form 0.9.1 → 0.9.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -1
- data/CONTRIBUTING.md +146 -0
- data/Gemfile.lock +1 -1
- data/README.md +76 -44
- data/lib/rails_bootstrap_form/bootstrap_form_builder.rb +5 -2
- data/lib/rails_bootstrap_form/field_wrapper_builder.rb +50 -49
- data/lib/rails_bootstrap_form/helpers/buttons.rb +3 -3
- data/lib/rails_bootstrap_form/helpers/choice.rb +81 -0
- data/lib/rails_bootstrap_form/helpers/help_text.rb +3 -3
- data/lib/rails_bootstrap_form/helpers/labels.rb +16 -16
- data/lib/rails_bootstrap_form/helpers.rb +10 -11
- data/lib/rails_bootstrap_form/input_group_builder.rb +14 -14
- data/lib/rails_bootstrap_form/inputs/base.rb +21 -18
- data/lib/rails_bootstrap_form/inputs/check_box.rb +12 -20
- data/lib/rails_bootstrap_form/inputs/collection_check_boxes.rb +10 -5
- data/lib/rails_bootstrap_form/inputs/collection_radio_buttons.rb +10 -5
- data/lib/rails_bootstrap_form/inputs/collection_select.rb +3 -3
- data/lib/rails_bootstrap_form/inputs/color_field.rb +9 -4
- data/lib/rails_bootstrap_form/inputs/grouped_collection_select.rb +3 -3
- data/lib/rails_bootstrap_form/inputs/radio_button.rb +11 -19
- data/lib/rails_bootstrap_form/inputs/range_field.rb +4 -4
- data/lib/rails_bootstrap_form/inputs/rich_text_area.rb +3 -3
- data/lib/rails_bootstrap_form/inputs/select.rb +3 -3
- data/lib/rails_bootstrap_form/inputs/time_zone_select.rb +3 -3
- data/lib/rails_bootstrap_form/inputs/weekday_select.rb +3 -3
- data/lib/rails_bootstrap_form/version.rb +1 -1
- metadata +4 -4
- data/lib/rails_bootstrap_form/helpers/check_box.rb +0 -86
- data/lib/rails_bootstrap_form/helpers/radio_button.rb +0 -82
@@ -0,0 +1,81 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# -*- frozen_string_literal: true -*-
|
3
|
+
# -*- warn_indent: true -*-
|
4
|
+
|
5
|
+
module RailsBootstrapForm
|
6
|
+
module Helpers
|
7
|
+
module Choice
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
def self.included(base_class)
|
11
|
+
[:check_box, :radio_button].each do |tag_name|
|
12
|
+
define_method("#{tag_name}_label") do |attribute, value, options, bootstrap|
|
13
|
+
label_options = {
|
14
|
+
class: choice_label_classes(attribute, bootstrap, options)
|
15
|
+
}
|
16
|
+
label_options[:value] = value if tag_name.eql?(:radio_button)
|
17
|
+
label_options[:for] = options[:id] if options[:id].present?
|
18
|
+
|
19
|
+
label_text = label_text(attribute, bootstrap)
|
20
|
+
|
21
|
+
label(attribute, label_text, label_options)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
[:check_box, :radio_button].each do |tag_name|
|
26
|
+
define_method("bootstrap_#{tag_name}") do |attribute, value, options, bootstrap|
|
27
|
+
options[:class] = choice_classes(attribute, options)
|
28
|
+
|
29
|
+
if tag_name.eql?(:check_box)
|
30
|
+
choice_field = check_box_without_bootstrap(attribute, options, value, nil)
|
31
|
+
choice_label = check_box_label(attribute, value, options, bootstrap)
|
32
|
+
else
|
33
|
+
choice_field = radio_button_without_bootstrap(attribute, value, options)
|
34
|
+
choice_label = radio_button_label(attribute, value, options, bootstrap)
|
35
|
+
end
|
36
|
+
|
37
|
+
choice_field + choice_label
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def choice_classes(attribute, options)
|
42
|
+
classes = Array("form-check-input") << options[:class]
|
43
|
+
classes << "is-invalid" if is_invalid?(attribute)
|
44
|
+
classes.flatten.compact
|
45
|
+
end
|
46
|
+
|
47
|
+
def choice_label_classes(attribute, bootstrap, options)
|
48
|
+
classes = Array("form-check-label") << bootstrap.additional_label_class
|
49
|
+
classes << "required" if is_field_required?(attribute, options)
|
50
|
+
classes << "is-invalid" if is_invalid?(attribute)
|
51
|
+
classes << bootstrap.hide_class if bootstrap.hide_label?
|
52
|
+
classes.flatten.compact
|
53
|
+
end
|
54
|
+
|
55
|
+
def choice_container_classes(bootstrap)
|
56
|
+
classes = Array(bootstrap.field_col_wrapper_class)
|
57
|
+
classes << field_offset_class(bootstrap.label_col_wrapper_class)
|
58
|
+
classes.flatten.compact
|
59
|
+
end
|
60
|
+
|
61
|
+
def choice_wrapper_classes(bootstrap)
|
62
|
+
classes = Array("form-check")
|
63
|
+
classes << "form-check-inline" if bootstrap.inline?
|
64
|
+
classes << "form-switch" if bootstrap.switch?
|
65
|
+
classes.flatten.compact
|
66
|
+
end
|
67
|
+
|
68
|
+
def collection_input_checked?(checked, obj, input_value)
|
69
|
+
checked == input_value || Array(checked).try(:include?, input_value) ||
|
70
|
+
checked == obj || Array(checked).try(:include?, obj)
|
71
|
+
end
|
72
|
+
|
73
|
+
private :choice_classes, :choice_label_classes,
|
74
|
+
:choice_container_classes, :choice_wrapper_classes,
|
75
|
+
:check_box_label, :radio_button_label,
|
76
|
+
:bootstrap_check_box, :bootstrap_radio_button,
|
77
|
+
:collection_input_checked?
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -8,10 +8,10 @@ module RailsBootstrapForm
|
|
8
8
|
extend ActiveSupport::Concern
|
9
9
|
|
10
10
|
def self.included(base_class)
|
11
|
-
def help_text(attribute,
|
12
|
-
return if
|
11
|
+
def help_text(attribute, bootstrap)
|
12
|
+
return if bootstrap.help_text == false
|
13
13
|
|
14
|
-
help_text = (
|
14
|
+
help_text = (bootstrap.help_text || scoped_help_text(attribute))
|
15
15
|
|
16
16
|
tag.div(help_text, class: "form-text text-muted") if help_text.present?
|
17
17
|
end
|
@@ -8,42 +8,42 @@ module RailsBootstrapForm
|
|
8
8
|
extend ActiveSupport::Concern
|
9
9
|
|
10
10
|
def self.included(base_class)
|
11
|
-
def draw_label(attribute, options,
|
12
|
-
unless
|
11
|
+
def draw_label(attribute, options, bootstrap)
|
12
|
+
unless bootstrap.skip_label? && !bootstrap.floating?
|
13
13
|
label_options = {
|
14
|
-
class: label_classes(attribute, options,
|
14
|
+
class: label_classes(attribute, options, bootstrap)
|
15
15
|
}
|
16
16
|
label_options[:for] = options[:id] if options[:id].present?
|
17
|
-
label_text = label_text(attribute,
|
17
|
+
label_text = label_text(attribute, bootstrap)
|
18
18
|
|
19
19
|
label(attribute, label_text, label_options)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def label_classes(attribute, options,
|
23
|
+
def label_classes(attribute, options, bootstrap)
|
24
24
|
classes = []
|
25
|
-
classes << label_layout_classes(
|
26
|
-
classes <<
|
27
|
-
classes <<
|
25
|
+
classes << label_layout_classes(bootstrap)
|
26
|
+
classes << bootstrap.additional_label_class
|
27
|
+
classes << bootstrap.hide_class if hide_class_required?(bootstrap)
|
28
28
|
classes << "required" if is_field_required?(attribute, options)
|
29
29
|
classes << "is-invalid" if is_invalid?(attribute)
|
30
30
|
classes.flatten.compact
|
31
31
|
end
|
32
32
|
|
33
|
-
def label_layout_classes(
|
34
|
-
if
|
35
|
-
[
|
33
|
+
def label_layout_classes(bootstrap)
|
34
|
+
if bootstrap.layout_horizontal?
|
35
|
+
[bootstrap.label_col_class, bootstrap.label_col_wrapper_class]
|
36
36
|
else
|
37
|
-
|
37
|
+
bootstrap.label_class
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
def label_text(attribute,
|
42
|
-
|
41
|
+
def label_text(attribute, bootstrap)
|
42
|
+
bootstrap.label_text || object&.class.try(:human_attribute_name, attribute)
|
43
43
|
end
|
44
44
|
|
45
|
-
def hide_class_required?(
|
46
|
-
|
45
|
+
def hide_class_required?(bootstrap)
|
46
|
+
bootstrap.hide_label? || (bootstrap.layout_inline? && !bootstrap.floating?)
|
47
47
|
end
|
48
48
|
|
49
49
|
private :draw_label, :label_classes, :label_text, :label_layout_classes,
|
@@ -11,30 +11,29 @@ module RailsBootstrapForm
|
|
11
11
|
autoload :Labels
|
12
12
|
autoload :RequiredField
|
13
13
|
autoload :Errors
|
14
|
-
autoload :CheckBox
|
15
|
-
autoload :RadioButton
|
16
14
|
autoload :Buttons
|
15
|
+
autoload :Choice
|
17
16
|
|
18
17
|
include HelpText
|
19
18
|
include Labels
|
20
19
|
include RequiredField
|
21
20
|
include Errors
|
22
|
-
include CheckBox
|
23
|
-
include RadioButton
|
24
21
|
include Buttons
|
22
|
+
include Choice
|
25
23
|
|
26
24
|
def self.included(base_class)
|
27
|
-
def
|
28
|
-
|
29
|
-
|
25
|
+
def sanitized_tag_name(attribute, value)
|
26
|
+
# label's `for` attribute needs to match checkbox/radio button tag's id, IE sanitized value, IE
|
27
|
+
# https://github.com/rails/rails/blob/5-0-stable/actionview/lib/action_view/helpers/tags/base.rb#L123-L125
|
28
|
+
"#{@object_name}_#{attribute}_#{value.to_s.gsub(/\s/, "_").gsub(/[^-[[:word:]]]/, "").mb_chars.downcase}"
|
30
29
|
end
|
31
30
|
|
32
31
|
def control_specific_class(field_tag_name)
|
33
32
|
"rails-bootstrap-forms-#{field_tag_name.to_s.tr("_", "-")}"
|
34
33
|
end
|
35
34
|
|
36
|
-
def is_size_valid?(
|
37
|
-
|
35
|
+
def is_size_valid?(bootstrap)
|
36
|
+
bootstrap.size && %i(sm lg).include?(bootstrap.size)
|
38
37
|
end
|
39
38
|
|
40
39
|
def field_offset_class(label_col_wrapper_class)
|
@@ -52,8 +51,8 @@ module RailsBootstrapForm
|
|
52
51
|
options.delete(:class) if options[:class].blank?
|
53
52
|
end
|
54
53
|
|
55
|
-
private :
|
56
|
-
:
|
54
|
+
private :control_specific_class, :is_size_valid?, :add_css_class!,
|
55
|
+
:remove_css_class!
|
57
56
|
end
|
58
57
|
end
|
59
58
|
end
|
@@ -7,17 +7,17 @@ module RailsBootstrapForm
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
def self.included(base_class)
|
10
|
-
def input_group_wrapper(attribute,
|
10
|
+
def input_group_wrapper(attribute, bootstrap, &block)
|
11
11
|
input = capture(&block) || ActiveSupport::SafeBuffer.new
|
12
12
|
|
13
|
-
if input_group_required?(
|
14
|
-
prepend = attach_input(
|
15
|
-
append = attach_input(
|
13
|
+
if input_group_required?(bootstrap)
|
14
|
+
prepend = attach_input(bootstrap, :prepend)
|
15
|
+
append = attach_input(bootstrap, :append)
|
16
16
|
|
17
17
|
input = prepend + input + append
|
18
18
|
input += generate_error(attribute)
|
19
19
|
|
20
|
-
input = tag.div(input, class: input_group_classes(attribute,
|
20
|
+
input = tag.div(input, class: input_group_classes(attribute, bootstrap))
|
21
21
|
else
|
22
22
|
input += generate_error(attribute)
|
23
23
|
end
|
@@ -25,18 +25,18 @@ module RailsBootstrapForm
|
|
25
25
|
input
|
26
26
|
end
|
27
27
|
|
28
|
-
def input_group_classes(attribute,
|
29
|
-
classes = Array("input-group") <<
|
30
|
-
if is_size_valid?(
|
31
|
-
classes << "input-group-#{
|
28
|
+
def input_group_classes(attribute, bootstrap)
|
29
|
+
classes = Array("input-group") << bootstrap.additional_input_group_class
|
30
|
+
if is_size_valid?(bootstrap)
|
31
|
+
classes << "input-group-#{bootstrap.size}"
|
32
32
|
end
|
33
33
|
# Require `has-validation` class if field has errors.
|
34
34
|
classes << "has-validation" if is_invalid?(attribute)
|
35
35
|
classes.flatten.compact
|
36
36
|
end
|
37
37
|
|
38
|
-
def attach_input(
|
39
|
-
tags = [*
|
38
|
+
def attach_input(bootstrap, key)
|
39
|
+
tags = [*bootstrap.send(key)].map do |item|
|
40
40
|
input_group_content(item)
|
41
41
|
end
|
42
42
|
|
@@ -49,10 +49,10 @@ module RailsBootstrapForm
|
|
49
49
|
tag.span(content.html_safe, class: "input-group-text")
|
50
50
|
end
|
51
51
|
|
52
|
-
def input_group_required?(
|
52
|
+
def input_group_required?(bootstrap)
|
53
53
|
[
|
54
|
-
|
55
|
-
|
54
|
+
bootstrap.prepend,
|
55
|
+
bootstrap.append
|
56
56
|
].any?(&:present?)
|
57
57
|
end
|
58
58
|
|
@@ -8,23 +8,26 @@ module RailsBootstrapForm
|
|
8
8
|
extend ActiveSupport::Concern
|
9
9
|
|
10
10
|
included do
|
11
|
-
def inputs_collection(attribute, collection, value_method, text_method,
|
11
|
+
def inputs_collection(attribute, collection, value_method, text_method, bootstrap, options = {})
|
12
12
|
inputs = ActiveSupport::SafeBuffer.new
|
13
13
|
|
14
14
|
collection.each do |object|
|
15
|
+
value = object.send(value_method)
|
16
|
+
|
15
17
|
input_options = {
|
16
18
|
bootstrap: {
|
17
19
|
label_text: text_method.respond_to?(:call) ? text_method.call(object) : object.send(text_method),
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
inline: bootstrap.inline?
|
21
|
+
},
|
22
|
+
required: false,
|
23
|
+
id: sanitized_tag_name(attribute, value)
|
21
24
|
}.deep_merge!(options)
|
22
25
|
|
23
26
|
if (checked = input_options[:checked])
|
24
|
-
input_options[:checked] = collection_input_checked?(checked, object,
|
27
|
+
input_options[:checked] = collection_input_checked?(checked, object, value)
|
25
28
|
end
|
26
29
|
|
27
|
-
input_value = value_method.respond_to?(:call) ? value_method.call(object) :
|
30
|
+
input_value = value_method.respond_to?(:call) ? value_method.call(object) : value
|
28
31
|
|
29
32
|
inputs << yield(attribute, input_value, input_options)
|
30
33
|
end
|
@@ -34,26 +37,26 @@ module RailsBootstrapForm
|
|
34
37
|
end
|
35
38
|
|
36
39
|
class_methods do
|
37
|
-
def bootstrap_field(
|
38
|
-
define_method(
|
39
|
-
|
40
|
-
return super(attribute, options) if
|
40
|
+
def bootstrap_field(tag_name)
|
41
|
+
define_method(tag_name) do |attribute, options = {}|
|
42
|
+
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
43
|
+
return super(attribute, options) if bootstrap.disabled?
|
41
44
|
|
42
|
-
field_wrapper_builder(attribute,
|
45
|
+
field_wrapper_builder(attribute, bootstrap, options) do
|
43
46
|
super(attribute, options)
|
44
47
|
end
|
45
48
|
end
|
46
49
|
end
|
47
50
|
|
48
|
-
def bootstrap_select_group(
|
49
|
-
define_method(
|
50
|
-
options = {bootstrap: {field_class: "form-select"}}.deep_merge!(options)
|
51
|
+
def bootstrap_select_group(tag_name)
|
52
|
+
define_method(tag_name) do |attribute, options = {}, html_options = {}|
|
53
|
+
options = {bootstrap: {field_class: "form-select", floating: false}}.deep_merge!(options)
|
51
54
|
|
52
|
-
|
53
|
-
return super(attribute, options, html_options) if
|
55
|
+
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
56
|
+
return super(attribute, options, html_options) if bootstrap.disabled?
|
54
57
|
|
55
|
-
field_wrapper_builder(attribute,
|
56
|
-
tag.fieldset(class: control_specific_class(
|
58
|
+
field_wrapper_builder(attribute, bootstrap, options, html_options) do
|
59
|
+
tag.fieldset(class: control_specific_class(tag_name)) do
|
57
60
|
super(attribute, options, html_options)
|
58
61
|
end
|
59
62
|
end
|
@@ -8,32 +8,24 @@ module RailsBootstrapForm
|
|
8
8
|
extend ActiveSupport::Concern
|
9
9
|
|
10
10
|
included do
|
11
|
-
def check_box(attribute, options = {}, checked_value = "1", unchecked_value = "0"
|
12
|
-
|
13
|
-
return super if
|
11
|
+
def check_box(attribute, options = {}, checked_value = "1", unchecked_value = "0")
|
12
|
+
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
13
|
+
return super if bootstrap.disabled?
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
check_box_label = check_box_label(attribute, checked_value, options, bootstrap_options, &block)
|
21
|
-
|
22
|
-
check_box_html = tag.div(**check_box_wrapper_options(bootstrap_options)) do
|
23
|
-
concat(check_box_field)
|
24
|
-
concat(check_box_label)
|
25
|
-
concat(check_box_help_text)
|
26
|
-
concat(generate_error(attribute)) if (is_invalid?(attribute) && !bootstrap_options.inline?)
|
15
|
+
check_box_html = tag.div(class: choice_wrapper_classes(bootstrap)) do
|
16
|
+
concat(bootstrap_check_box(attribute, checked_value, options, bootstrap))
|
17
|
+
concat(help_text(attribute, bootstrap))
|
18
|
+
concat(generate_error(attribute)) if is_invalid?(attribute)
|
27
19
|
end
|
28
20
|
|
29
|
-
if
|
30
|
-
tag.div(
|
31
|
-
|
21
|
+
if bootstrap.wrapper
|
22
|
+
tag.div(**field_wrapper_options(bootstrap)) do
|
23
|
+
if bootstrap.layout_horizontal?
|
24
|
+
tag.div(class: choice_container_classes(bootstrap)) { check_box_html }
|
25
|
+
else
|
32
26
|
check_box_html
|
33
27
|
end
|
34
28
|
end
|
35
|
-
elsif bootstrap_options.layout_inline?
|
36
|
-
tag.div(class: "col-12") { check_box_html }
|
37
29
|
else
|
38
30
|
check_box_html
|
39
31
|
end
|
@@ -9,18 +9,23 @@ module RailsBootstrapForm
|
|
9
9
|
|
10
10
|
included do
|
11
11
|
def collection_check_boxes(attribute, collection, value_method, text_method, options = {}, html_options = {})
|
12
|
-
|
13
|
-
|
12
|
+
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
13
|
+
bootstrap.floating = false
|
14
|
+
return super if bootstrap.disabled?
|
14
15
|
|
15
|
-
inputs = inputs_collection(attribute, collection, value_method, text_method,
|
16
|
-
|
16
|
+
inputs = inputs_collection(attribute, collection, value_method, text_method, bootstrap, options) do |attribute, value, options|
|
17
|
+
bootstrap_opts = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
18
|
+
|
19
|
+
tag.div(class: choice_wrapper_classes(bootstrap_opts)) do
|
20
|
+
bootstrap_check_box(attribute, value, options, bootstrap_opts)
|
21
|
+
end
|
17
22
|
end
|
18
23
|
|
19
24
|
if options.delete(:include_hidden) { true }
|
20
25
|
inputs.prepend(hidden_field(attribute, value: "", multiple: options[:multiple]))
|
21
26
|
end
|
22
27
|
|
23
|
-
field_wrapper_builder(attribute,
|
28
|
+
field_wrapper_builder(attribute, bootstrap, options, html_options) do
|
24
29
|
concat(tag.div(class: control_specific_class(:collection_check_boxes)) do
|
25
30
|
concat(inputs)
|
26
31
|
end)
|
@@ -9,14 +9,19 @@ module RailsBootstrapForm
|
|
9
9
|
|
10
10
|
included do
|
11
11
|
def collection_radio_buttons(attribute, collection, value_method, text_method, options = {}, html_options = {})
|
12
|
-
|
13
|
-
|
12
|
+
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
13
|
+
bootstrap.floating = false
|
14
|
+
return super if bootstrap.disabled?
|
14
15
|
|
15
|
-
inputs = inputs_collection(attribute, collection, value_method, text_method,
|
16
|
-
|
16
|
+
inputs = inputs_collection(attribute, collection, value_method, text_method, bootstrap, options) do |attribute, value, options|
|
17
|
+
bootstrap_opts = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
18
|
+
|
19
|
+
tag.div(class: choice_wrapper_classes(bootstrap_opts)) do
|
20
|
+
bootstrap_radio_button(attribute, value, options, bootstrap_opts)
|
21
|
+
end
|
17
22
|
end
|
18
23
|
|
19
|
-
field_wrapper_builder(attribute,
|
24
|
+
field_wrapper_builder(attribute, bootstrap, options, html_options) do
|
20
25
|
concat(tag.div(class: control_specific_class(:collection_radio_buttons)) do
|
21
26
|
concat(inputs)
|
22
27
|
end)
|
@@ -11,10 +11,10 @@ module RailsBootstrapForm
|
|
11
11
|
def collection_select(attribute, collection, value_method, text_method, options = {}, html_options = {})
|
12
12
|
options = {bootstrap: {field_class: "form-select"}}.deep_merge!(options)
|
13
13
|
|
14
|
-
|
15
|
-
return super if
|
14
|
+
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
15
|
+
return super if bootstrap.disabled?
|
16
16
|
|
17
|
-
field_wrapper_builder(attribute,
|
17
|
+
field_wrapper_builder(attribute, bootstrap, options, html_options) do
|
18
18
|
super(attribute, collection, value_method, text_method, options, html_options)
|
19
19
|
end
|
20
20
|
end
|
@@ -9,12 +9,17 @@ module RailsBootstrapForm
|
|
9
9
|
|
10
10
|
included do
|
11
11
|
def color_field(attribute, options = {})
|
12
|
-
options = {
|
12
|
+
options = {
|
13
|
+
bootstrap: {
|
14
|
+
field_class: "form-control form-control-color",
|
15
|
+
floating: false
|
16
|
+
}
|
17
|
+
}.deep_merge!(options)
|
13
18
|
|
14
|
-
|
15
|
-
return super if
|
19
|
+
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
20
|
+
return super if bootstrap.disabled?
|
16
21
|
|
17
|
-
field_wrapper_builder(attribute,
|
22
|
+
field_wrapper_builder(attribute, bootstrap, options) do
|
18
23
|
super(attribute, options)
|
19
24
|
end
|
20
25
|
end
|
@@ -11,10 +11,10 @@ module RailsBootstrapForm
|
|
11
11
|
def grouped_collection_select(attribute, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {})
|
12
12
|
options = {bootstrap: {field_class: "form-select"}}.deep_merge!(options)
|
13
13
|
|
14
|
-
|
15
|
-
return super if
|
14
|
+
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
15
|
+
return super if bootstrap.disabled?
|
16
16
|
|
17
|
-
field_wrapper_builder(attribute,
|
17
|
+
field_wrapper_builder(attribute, bootstrap, options, html_options) do
|
18
18
|
super(attribute, collection, group_method, group_label_method, option_key_method, option_value_method, options, html_options)
|
19
19
|
end
|
20
20
|
end
|
@@ -9,31 +9,23 @@ module RailsBootstrapForm
|
|
9
9
|
|
10
10
|
included do
|
11
11
|
def radio_button(attribute, value, options = {})
|
12
|
-
|
13
|
-
return super if
|
12
|
+
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
13
|
+
return super if bootstrap.disabled?
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
radio_button_label = radio_button_label(attribute, value, options, bootstrap_options)
|
21
|
-
|
22
|
-
radio_button_html = tag.div(**radio_button_wrapper_options(bootstrap_options)) do
|
23
|
-
concat(radio_button_field)
|
24
|
-
concat(radio_button_label)
|
25
|
-
concat(radio_button_help_text)
|
26
|
-
concat(generate_error(attribute)) if (is_invalid?(attribute) && !bootstrap_options.inline?)
|
15
|
+
radio_button_html = tag.div(class: choice_wrapper_classes(bootstrap)) do
|
16
|
+
concat(bootstrap_radio_button(attribute, value, options, bootstrap))
|
17
|
+
concat(help_text(attribute, bootstrap))
|
18
|
+
concat(generate_error(attribute)) if is_invalid?(attribute)
|
27
19
|
end
|
28
20
|
|
29
|
-
if
|
30
|
-
tag.div(
|
31
|
-
|
21
|
+
if bootstrap.wrapper
|
22
|
+
tag.div(**field_wrapper_options(bootstrap)) do
|
23
|
+
if bootstrap.layout_horizontal?
|
24
|
+
tag.div(class: choice_container_classes(bootstrap)) { radio_button_html }
|
25
|
+
else
|
32
26
|
radio_button_html
|
33
27
|
end
|
34
28
|
end
|
35
|
-
elsif bootstrap_options.layout_inline?
|
36
|
-
tag.div(class: "col-12") { radio_button_html }
|
37
29
|
else
|
38
30
|
radio_button_html
|
39
31
|
end
|
@@ -9,12 +9,12 @@ module RailsBootstrapForm
|
|
9
9
|
|
10
10
|
included do
|
11
11
|
def range_field(attribute, options = {})
|
12
|
-
options = {bootstrap: {field_class: "form-range"}}.deep_merge!(options)
|
12
|
+
options = {bootstrap: {field_class: "form-range", floating: false}}.deep_merge!(options)
|
13
13
|
|
14
|
-
|
15
|
-
return super if
|
14
|
+
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
15
|
+
return super if bootstrap.disabled?
|
16
16
|
|
17
|
-
field_wrapper_builder(attribute,
|
17
|
+
field_wrapper_builder(attribute, bootstrap, options) do
|
18
18
|
super(attribute, options)
|
19
19
|
end
|
20
20
|
end
|
@@ -11,10 +11,10 @@ module RailsBootstrapForm
|
|
11
11
|
def rich_text_area(attribute, options = {})
|
12
12
|
options[:class] = ["trix-content", options[:class]].compact.join(" ")
|
13
13
|
|
14
|
-
|
15
|
-
return super if
|
14
|
+
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
15
|
+
return super if bootstrap.disabled?
|
16
16
|
|
17
|
-
field_wrapper_builder(attribute,
|
17
|
+
field_wrapper_builder(attribute, bootstrap, options) do
|
18
18
|
super(attribute, options)
|
19
19
|
end
|
20
20
|
end
|
@@ -11,10 +11,10 @@ module RailsBootstrapForm
|
|
11
11
|
def select(attribute, choices = nil, options = {}, html_options = {}, &block)
|
12
12
|
options = {bootstrap: {field_class: "form-select"}}.deep_merge!(options)
|
13
13
|
|
14
|
-
|
15
|
-
return super if
|
14
|
+
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
15
|
+
return super if bootstrap.disabled?
|
16
16
|
|
17
|
-
field_wrapper_builder(attribute,
|
17
|
+
field_wrapper_builder(attribute, bootstrap, options, html_options) do
|
18
18
|
super(attribute, choices, options, html_options, &block)
|
19
19
|
end
|
20
20
|
end
|
@@ -11,10 +11,10 @@ module RailsBootstrapForm
|
|
11
11
|
def time_zone_select(attribute, priority_zones = nil, options = {}, html_options = {})
|
12
12
|
options = {bootstrap: {field_class: "form-select"}}.deep_merge!(options)
|
13
13
|
|
14
|
-
|
15
|
-
return super if
|
14
|
+
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
15
|
+
return super if bootstrap.disabled?
|
16
16
|
|
17
|
-
field_wrapper_builder(attribute,
|
17
|
+
field_wrapper_builder(attribute, bootstrap, options, html_options) do
|
18
18
|
super(attribute, priority_zones, options, html_options)
|
19
19
|
end
|
20
20
|
end
|
@@ -11,10 +11,10 @@ module RailsBootstrapForm
|
|
11
11
|
def weekday_select(attribute, options = {}, html_options = {}, &block)
|
12
12
|
options = {bootstrap: {field_class: "form-select"}}.deep_merge!(options)
|
13
13
|
|
14
|
-
|
15
|
-
return super if
|
14
|
+
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
15
|
+
return super if bootstrap.disabled?
|
16
16
|
|
17
|
-
field_wrapper_builder(attribute,
|
17
|
+
field_wrapper_builder(attribute, bootstrap, options, html_options) do
|
18
18
|
super(attribute, options, html_options, &block)
|
19
19
|
end
|
20
20
|
end
|