rails_bootstrap_form 0.9.7 → 0.9.9
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/.codeclimate.yml +47 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +1 -1
- data/README.md +15 -12
- data/demo/config/initializers/rails_bootstrap_form.rb +1 -1
- data/lib/rails_bootstrap_form/action_view_extensions/bootstrap_form_helper.rb +2 -2
- data/lib/rails_bootstrap_form/bootstrap_form_builder.rb +3 -3
- data/lib/rails_bootstrap_form/bootstrap_form_options.rb +2 -2
- data/lib/rails_bootstrap_form/field_wrapper_builder.rb +64 -36
- data/lib/rails_bootstrap_form/helpers/buttons.rb +50 -20
- data/lib/rails_bootstrap_form/helpers/choice.rb +70 -54
- data/lib/rails_bootstrap_form/helpers/errors.rb +48 -38
- data/lib/rails_bootstrap_form/helpers/help_text.rb +27 -30
- data/lib/rails_bootstrap_form/helpers/labels.rb +31 -34
- data/lib/rails_bootstrap_form/helpers/required_field.rb +41 -37
- data/lib/rails_bootstrap_form/helpers.rb +23 -31
- data/lib/rails_bootstrap_form/input_group_builder.rb +36 -39
- data/lib/rails_bootstrap_form/inputs/base.rb +32 -16
- data/lib/rails_bootstrap_form/inputs/check_box.rb +2 -12
- data/lib/rails_bootstrap_form/inputs/radio_button.rb +2 -12
- data/lib/rails_bootstrap_form/version.rb +1 -1
- metadata +3 -2
@@ -7,59 +7,69 @@ module RailsBootstrapForm
|
|
7
7
|
module Errors
|
8
8
|
extend ActiveSupport::Concern
|
9
9
|
|
10
|
-
|
11
|
-
def is_invalid?(attribute)
|
12
|
-
(attribute && object.respond_to?(:errors) && object.errors[attribute].any?) ||
|
13
|
-
has_association_error?(attribute)
|
14
|
-
end
|
10
|
+
private
|
15
11
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
# end
|
12
|
+
def is_invalid?(attribute)
|
13
|
+
(attribute && object.respond_to?(:errors) && has_attribute_error?(attribute)) ||
|
14
|
+
has_association_error?(attribute)
|
15
|
+
end
|
21
16
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
def generate_error(attribute)
|
18
|
+
if is_invalid?(attribute)
|
19
|
+
error_text = error_messages(attribute)
|
20
|
+
error_klass = "invalid-feedback"
|
26
21
|
|
27
|
-
|
28
|
-
end
|
22
|
+
tag.div(error_text, class: error_klass)
|
29
23
|
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def error_messages(attribute)
|
27
|
+
messages = Array(attribute_error_messages(attribute))
|
28
|
+
messages << associated_error_messages(attribute)
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
messages.flatten.to_sentence
|
31
|
+
end
|
32
|
+
|
33
|
+
def has_attribute_error?(attribute)
|
34
|
+
attribute_error_messages(attribute).any?
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
def has_association_error?(attribute)
|
38
|
+
object.class.try(:reflections)&.any? do |association_name, association|
|
39
|
+
has_errors_on_association?(attribute, association_name)
|
38
40
|
end
|
41
|
+
end
|
39
42
|
|
40
|
-
|
41
|
-
|
43
|
+
def has_errors_on_association?(attribute, association_name)
|
44
|
+
return false unless is_belongs_to_association?(object.class.reflections[association_name])
|
45
|
+
return false unless is_association_same?(attribute, object.class.reflections[association_name])
|
42
46
|
|
43
|
-
|
44
|
-
|
45
|
-
next unless is_association_same?(attribute, association)
|
47
|
+
object.errors[association_name].any?
|
48
|
+
end
|
46
49
|
|
47
|
-
|
48
|
-
|
50
|
+
def attribute_error_messages(attribute)
|
51
|
+
object.errors[attribute]
|
52
|
+
end
|
49
53
|
|
50
|
-
|
51
|
-
|
54
|
+
def associated_error_messages(attribute)
|
55
|
+
error_messages = []
|
52
56
|
|
53
|
-
|
54
|
-
|
55
|
-
|
57
|
+
object.class.try(:reflections)&.each do |association_name, association|
|
58
|
+
next unless is_belongs_to_association?(association)
|
59
|
+
next unless is_association_same?(attribute, association)
|
56
60
|
|
57
|
-
|
58
|
-
(association.foreign_key == attribute.to_s)
|
61
|
+
error_messages << object.errors[association_name]
|
59
62
|
end
|
60
63
|
|
61
|
-
|
62
|
-
|
64
|
+
error_messages
|
65
|
+
end
|
66
|
+
|
67
|
+
def is_belongs_to_association?(association)
|
68
|
+
association.is_a?(ActiveRecord::Reflection::BelongsToReflection)
|
69
|
+
end
|
70
|
+
|
71
|
+
def is_association_same?(attribute, association)
|
72
|
+
(association.foreign_key == attribute.to_s)
|
63
73
|
end
|
64
74
|
end
|
65
75
|
end
|
@@ -7,46 +7,43 @@ module RailsBootstrapForm
|
|
7
7
|
module HelpText
|
8
8
|
extend ActiveSupport::Concern
|
9
9
|
|
10
|
-
|
11
|
-
def help_text(attribute, bootstrap)
|
12
|
-
return if bootstrap.help_text == false
|
10
|
+
private
|
13
11
|
|
14
|
-
|
12
|
+
def help_text(attribute, bootstrap)
|
13
|
+
return if bootstrap.help_text == false
|
15
14
|
|
16
|
-
|
17
|
-
end
|
15
|
+
help_text = (bootstrap.help_text || scoped_help_text(attribute))
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
object.respond_to?(:klass) && object.klass.is_a?(ActiveModel::Naming)
|
22
|
-
object.klass
|
23
|
-
else
|
24
|
-
object.class
|
25
|
-
end
|
26
|
-
end
|
17
|
+
tag.div(help_text, class: "form-text text-muted") if help_text.present?
|
18
|
+
end
|
27
19
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
20
|
+
def object_class
|
21
|
+
if !object.class.is_a?(ActiveModel::Naming) &&
|
22
|
+
object.respond_to?(:klass) && object.klass.is_a?(ActiveModel::Naming)
|
23
|
+
object.klass
|
24
|
+
else
|
25
|
+
object.class
|
34
26
|
end
|
27
|
+
end
|
35
28
|
|
36
|
-
|
37
|
-
|
29
|
+
def partial_scope
|
30
|
+
if object_class.respond_to?(:model_name)
|
31
|
+
object_class.model_name.name
|
32
|
+
else
|
33
|
+
object_class.name
|
34
|
+
end
|
35
|
+
end
|
38
36
|
|
39
|
-
|
37
|
+
def scoped_help_text(attribute)
|
38
|
+
translation_scope = "activerecord.help_texts.#{partial_scope.underscore}"
|
40
39
|
|
41
|
-
|
42
|
-
end
|
40
|
+
help_text = translated_help_text(attribute, translation_scope).presence
|
43
41
|
|
44
|
-
|
45
|
-
|
46
|
-
end
|
42
|
+
help_text
|
43
|
+
end
|
47
44
|
|
48
|
-
|
49
|
-
|
45
|
+
def translated_help_text(attribute, scope)
|
46
|
+
ActiveSupport::SafeBuffer.new(I18n.t(attribute, scope: scope, default: ""))
|
50
47
|
end
|
51
48
|
end
|
52
49
|
end
|
@@ -7,47 +7,44 @@ module RailsBootstrapForm
|
|
7
7
|
module Labels
|
8
8
|
extend ActiveSupport::Concern
|
9
9
|
|
10
|
-
|
11
|
-
def draw_label(attribute, options, bootstrap)
|
12
|
-
unless bootstrap.skip_label? && !bootstrap.floating?
|
13
|
-
label_options = {
|
14
|
-
class: label_classes(attribute, options, bootstrap)
|
15
|
-
}
|
16
|
-
label_options[:for] = options[:id] if options[:id].present?
|
17
|
-
label_text = label_text(attribute, bootstrap)
|
18
|
-
|
19
|
-
label(attribute, label_text, label_options)
|
20
|
-
end
|
21
|
-
end
|
10
|
+
private
|
22
11
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
classes.flatten.compact
|
31
|
-
end
|
12
|
+
def draw_label(attribute, options, bootstrap)
|
13
|
+
unless bootstrap.skip_label? && !bootstrap.floating?
|
14
|
+
label_options = {
|
15
|
+
class: label_classes(attribute, options, bootstrap)
|
16
|
+
}
|
17
|
+
label_options[:for] = options[:id] if options[:id].present?
|
18
|
+
label_text = label_text(attribute, bootstrap)
|
32
19
|
|
33
|
-
|
34
|
-
if bootstrap.layout_horizontal?
|
35
|
-
[bootstrap.label_col_class, bootstrap.label_col_wrapper_class]
|
36
|
-
else
|
37
|
-
bootstrap.label_class
|
38
|
-
end
|
20
|
+
label(attribute, label_text, label_options)
|
39
21
|
end
|
22
|
+
end
|
40
23
|
|
41
|
-
|
42
|
-
|
43
|
-
|
24
|
+
def label_classes(attribute, options, bootstrap)
|
25
|
+
classes = []
|
26
|
+
classes << label_layout_classes(bootstrap)
|
27
|
+
classes << bootstrap.additional_label_class
|
28
|
+
classes << bootstrap.hide_class if hide_class_required?(bootstrap)
|
29
|
+
classes << "required" if is_field_required?(attribute, options)
|
30
|
+
classes << "is-invalid" if is_invalid?(attribute)
|
31
|
+
classes.flatten.compact
|
32
|
+
end
|
44
33
|
|
45
|
-
|
46
|
-
|
34
|
+
def label_layout_classes(bootstrap)
|
35
|
+
if bootstrap.layout_horizontal?
|
36
|
+
[bootstrap.label_col_class, bootstrap.label_col_wrapper_class]
|
37
|
+
else
|
38
|
+
bootstrap.label_class
|
47
39
|
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def label_text(attribute, bootstrap)
|
43
|
+
bootstrap.label_text || object&.class.try(:human_attribute_name, attribute)
|
44
|
+
end
|
48
45
|
|
49
|
-
|
50
|
-
|
46
|
+
def hide_class_required?(bootstrap)
|
47
|
+
bootstrap.hide_label? || (bootstrap.layout_inline? && !bootstrap.floating?)
|
51
48
|
end
|
52
49
|
end
|
53
50
|
end
|
@@ -7,57 +7,61 @@ module RailsBootstrapForm
|
|
7
7
|
module RequiredField
|
8
8
|
extend ActiveSupport::Concern
|
9
9
|
|
10
|
-
|
11
|
-
def is_field_required?(attribute, options)
|
12
|
-
return false unless attribute
|
10
|
+
private
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
def is_field_required?(attribute, options)
|
13
|
+
return false unless attribute
|
14
|
+
|
15
|
+
if options.key?(:required)
|
16
|
+
options[:required]
|
17
|
+
else
|
18
|
+
is_attribute_required?(attribute)
|
19
19
|
end
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
def required_field_options(attribute, options)
|
23
|
+
required = is_field_required?(attribute, options)
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
25
|
+
{}.tap do |option|
|
26
|
+
option[:aria] = {required: true} if required
|
27
|
+
option[:required] = required
|
28
28
|
end
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
|
31
|
+
def is_attribute_required?(attribute)
|
32
|
+
return false unless attribute
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
target = target_object(object)
|
35
|
+
return false unless target.respond_to?(:validators_on)
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
end
|
37
|
+
has_presence_validator?(target_validators(target, attribute)) || is_required_association?(target, attribute)
|
38
|
+
end
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
def target_object(object)
|
41
|
+
object.instance_of?(Class) ? object : object.class
|
42
|
+
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
target_validators.include?(ActiveRecord::Validations::PresenceValidator))
|
48
|
-
end
|
44
|
+
def target_validators(target, attribute)
|
45
|
+
target.validators_on(attribute).map(&:class)
|
46
|
+
end
|
49
47
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
def has_presence_validator?(target_validators)
|
49
|
+
target_validators.include?(ActiveModel::Validations::PresenceValidator) ||
|
50
|
+
(defined?(ActiveRecord::Validations::PresenceValidator) &&
|
51
|
+
target_validators.include?(ActiveRecord::Validations::PresenceValidator))
|
52
|
+
end
|
54
53
|
|
55
|
-
|
56
|
-
|
54
|
+
def is_required_association?(target, attribute)
|
55
|
+
target.try(:reflections)&.find do |name, reflection|
|
56
|
+
required_association?(reflection, attribute)
|
57
57
|
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def required_association?(reflection, attribute)
|
61
|
+
return false unless reflection.is_a?(ActiveRecord::Reflection::BelongsToReflection)
|
62
|
+
return false unless reflection.foreign_key == attribute.to_s
|
58
63
|
|
59
|
-
|
60
|
-
:has_presence_validator?, :is_required_association?
|
64
|
+
has_presence_validator?(target_validators(reflection.active_record, reflection.name))
|
61
65
|
end
|
62
66
|
end
|
63
67
|
end
|
@@ -21,37 +21,29 @@ module RailsBootstrapForm
|
|
21
21
|
include Buttons
|
22
22
|
include Choice
|
23
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
|
-
# def remove_css_class!(options, css_class)
|
49
|
-
# the_class = options[:class].to_s.split(" ")
|
50
|
-
# options[:class] = (the_class - [css_class]).compact.join(" ")
|
51
|
-
# options.delete(:class) if options[:class].blank?
|
52
|
-
# end
|
53
|
-
|
54
|
-
private :control_specific_class, :is_size_valid?, :add_css_class!
|
24
|
+
private
|
25
|
+
|
26
|
+
def sanitized_tag_name(attribute, value)
|
27
|
+
# label's `for` attribute needs to match checkbox/radio button tag's id, IE sanitized value, IE
|
28
|
+
# https://github.com/rails/rails/blob/5-0-stable/actionview/lib/action_view/helpers/tags/base.rb#L123-L125
|
29
|
+
"#{@object_name}_#{attribute}_#{value.to_s.gsub(/\s/, "_").gsub(/[^-[[:word:]]]/, "").mb_chars.downcase}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def field_offset_class(label_col_wrapper_class)
|
33
|
+
label_col_wrapper_class.gsub(/\bcol-(\w+)-(\d)\b/, 'offset-\1-\2')
|
34
|
+
end
|
35
|
+
|
36
|
+
def add_css_class!(options, css_class)
|
37
|
+
the_class = [options[:class], css_class].compact
|
38
|
+
options[:class] = the_class if the_class.present?
|
39
|
+
end
|
40
|
+
|
41
|
+
def control_specific_class(field_tag_name)
|
42
|
+
"rails-bootstrap-forms-#{field_tag_name.to_s.tr("_", "-")}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def is_size_valid?(bootstrap)
|
46
|
+
bootstrap.size && %i(sm lg).include?(bootstrap.size)
|
55
47
|
end
|
56
48
|
end
|
57
49
|
end
|
@@ -6,58 +6,55 @@ module RailsBootstrapForm
|
|
6
6
|
module InputGroupBuilder
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
|
-
|
10
|
-
def input_group_wrapper(attribute, bootstrap, &block)
|
11
|
-
input = capture(&block) || ActiveSupport::SafeBuffer.new
|
9
|
+
private
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
append = attach_input(bootstrap, :append)
|
11
|
+
def input_group_wrapper(attribute, bootstrap, &block)
|
12
|
+
input = capture(&block) || ActiveSupport::SafeBuffer.new
|
16
13
|
|
17
|
-
|
18
|
-
|
14
|
+
if input_group_required?(bootstrap)
|
15
|
+
prepend = attach_input(bootstrap, :prepend)
|
16
|
+
append = attach_input(bootstrap, :append)
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
input += generate_error(attribute)
|
23
|
-
end
|
18
|
+
input = prepend + input + append
|
19
|
+
input += generate_error(attribute)
|
24
20
|
|
25
|
-
input
|
21
|
+
input = tag.div(input, class: input_group_classes(attribute, bootstrap))
|
22
|
+
else
|
23
|
+
input += generate_error(attribute)
|
26
24
|
end
|
27
25
|
|
28
|
-
|
29
|
-
|
30
|
-
if is_size_valid?(bootstrap)
|
31
|
-
classes << "input-group-#{bootstrap.size}"
|
32
|
-
end
|
33
|
-
# Require `has-validation` class if field has errors.
|
34
|
-
classes << "has-validation" if is_invalid?(attribute)
|
35
|
-
classes.flatten.compact
|
36
|
-
end
|
26
|
+
input
|
27
|
+
end
|
37
28
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
29
|
+
def input_group_classes(attribute, bootstrap)
|
30
|
+
classes = Array("input-group") << bootstrap.additional_input_group_class
|
31
|
+
if is_size_valid?(bootstrap)
|
32
|
+
classes << "input-group-#{bootstrap.size}"
|
33
|
+
end
|
34
|
+
# Require `has-validation` class if field has errors.
|
35
|
+
classes << "has-validation" if is_invalid?(attribute)
|
36
|
+
classes.flatten.compact
|
37
|
+
end
|
42
38
|
|
43
|
-
|
39
|
+
def attach_input(bootstrap, key)
|
40
|
+
tags = [*bootstrap.send(key)].map do |item|
|
41
|
+
input_group_content(item)
|
44
42
|
end
|
45
43
|
|
46
|
-
|
47
|
-
|
44
|
+
ActiveSupport::SafeBuffer.new(tags.join)
|
45
|
+
end
|
48
46
|
|
49
|
-
|
50
|
-
|
47
|
+
def input_group_content(content)
|
48
|
+
return content if /button|submit/.match?(content)
|
51
49
|
|
52
|
-
|
53
|
-
|
54
|
-
bootstrap.prepend,
|
55
|
-
bootstrap.append
|
56
|
-
].any?(&:present?)
|
57
|
-
end
|
50
|
+
tag.span(content.html_safe, class: "input-group-text")
|
51
|
+
end
|
58
52
|
|
59
|
-
|
60
|
-
|
53
|
+
def input_group_required?(bootstrap)
|
54
|
+
[
|
55
|
+
bootstrap.prepend,
|
56
|
+
bootstrap.append
|
57
|
+
].any?(&:present?)
|
61
58
|
end
|
62
59
|
end
|
63
60
|
end
|
@@ -12,22 +12,8 @@ module RailsBootstrapForm
|
|
12
12
|
inputs = ActiveSupport::SafeBuffer.new
|
13
13
|
|
14
14
|
collection.each do |object|
|
15
|
-
|
16
|
-
|
17
|
-
input_options = {
|
18
|
-
bootstrap: {
|
19
|
-
label_text: text_method.respond_to?(:call) ? text_method.call(object) : object.send(text_method),
|
20
|
-
inline: (bootstrap.inline? || bootstrap.layout_inline?)
|
21
|
-
},
|
22
|
-
required: false,
|
23
|
-
id: sanitized_tag_name(attribute, value)
|
24
|
-
}.deep_merge!(options)
|
25
|
-
|
26
|
-
if (checked = input_options[:checked])
|
27
|
-
input_options[:checked] = collection_input_checked?(checked, object, value)
|
28
|
-
end
|
29
|
-
|
30
|
-
input_value = value_method.respond_to?(:call) ? value_method.call(object) : value
|
15
|
+
input_options = build_input_options(object, attribute, value_method, text_method, bootstrap, options)
|
16
|
+
input_value = resolve_input_value(object, value_method)
|
31
17
|
|
32
18
|
inputs << yield(attribute, input_value, input_options)
|
33
19
|
end
|
@@ -66,6 +52,36 @@ module RailsBootstrapForm
|
|
66
52
|
end
|
67
53
|
end
|
68
54
|
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def build_input_options(object, attribute, value_method, text_method, bootstrap, options)
|
59
|
+
input_options = {
|
60
|
+
bootstrap: {
|
61
|
+
label_text: resolve_label_text(text_method, object),
|
62
|
+
inline: (bootstrap.inline? || bootstrap.layout_inline?)
|
63
|
+
},
|
64
|
+
required: false,
|
65
|
+
id: sanitized_tag_name(attribute, object.send(value_method))
|
66
|
+
}.deep_merge!(options)
|
67
|
+
|
68
|
+
input_options[:checked] = resolve_checked_option(input_options[:checked], object, value_method)
|
69
|
+
|
70
|
+
input_options
|
71
|
+
end
|
72
|
+
|
73
|
+
def resolve_label_text(text_method, object)
|
74
|
+
text_method.respond_to?(:call) ? text_method.call(object) : object.send(text_method)
|
75
|
+
end
|
76
|
+
|
77
|
+
def resolve_input_value(object, value_method)
|
78
|
+
value_method.respond_to?(:call) ? value_method.call(object) : object.send(value_method)
|
79
|
+
end
|
80
|
+
|
81
|
+
def resolve_checked_option(checked_option, object, value_method)
|
82
|
+
return collection_input_checked?(checked_option, object, object.send(value_method)) if checked_option
|
83
|
+
false
|
84
|
+
end
|
69
85
|
end
|
70
86
|
end
|
71
87
|
end
|
@@ -12,20 +12,10 @@ module RailsBootstrapForm
|
|
12
12
|
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
13
13
|
return super if bootstrap.disabled?
|
14
14
|
|
15
|
-
check_box_html =
|
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)
|
19
|
-
end
|
15
|
+
check_box_html = build_check_box_html(attribute, checked_value, bootstrap, options)
|
20
16
|
|
21
17
|
if bootstrap.wrapper
|
22
|
-
|
23
|
-
if bootstrap.layout_horizontal?
|
24
|
-
tag.div(class: choice_container_classes(bootstrap)) { check_box_html }
|
25
|
-
else
|
26
|
-
check_box_html
|
27
|
-
end
|
28
|
-
end
|
18
|
+
build_wrapped_check_box_html(bootstrap, check_box_html)
|
29
19
|
else
|
30
20
|
check_box_html
|
31
21
|
end
|
@@ -12,20 +12,10 @@ module RailsBootstrapForm
|
|
12
12
|
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
13
13
|
return super if bootstrap.disabled?
|
14
14
|
|
15
|
-
radio_button_html =
|
16
|
-
concat(bootstrap_radio_button(attribute, value, options, bootstrap))
|
17
|
-
concat(help_text(attribute, bootstrap))
|
18
|
-
concat(generate_error(attribute)) if is_invalid?(attribute)
|
19
|
-
end
|
15
|
+
radio_button_html = build_radio_button_html(attribute, value, bootstrap, options)
|
20
16
|
|
21
17
|
if bootstrap.wrapper
|
22
|
-
|
23
|
-
if bootstrap.layout_horizontal?
|
24
|
-
tag.div(class: choice_container_classes(bootstrap)) { radio_button_html }
|
25
|
-
else
|
26
|
-
radio_button_html
|
27
|
-
end
|
28
|
-
end
|
18
|
+
build_wrapped_radio_button_html(bootstrap, radio_button_html)
|
29
19
|
else
|
30
20
|
radio_button_html
|
31
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_bootstrap_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harshal LADHE (shivam091)
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: generator_spec
|
@@ -60,6 +60,7 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
+
- ".codeclimate.yml"
|
63
64
|
- ".rspec"
|
64
65
|
- CHANGELOG.md
|
65
66
|
- CODE_OF_CONDUCT.md
|