rails_bootstrap_form 0.3.0 → 0.3.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70abffa048a738dda1992939b9169a40dd831c2d3413bab1cea5127283e53256
|
4
|
+
data.tar.gz: 179f8c46bdde787f36b8dd94d3dd1094cefebb64b6c282369590dde6c697026a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aab81e40e723cf1e83c169cd8b0a67e218a87c589ff3232d2a817ba9aa788ddf9eedb3f3887d7dc551776e2eaf5e3da66421b6b71d6b90a9f43c4446c4b244b5
|
7
|
+
data.tar.gz: 15e5b383cd6a6208f112edb2c0cba378e01b320d0728d122b216d7dc288279c3f78af2dad122814b313230944405616d960406a94084d19794d52b4f1e0939c8
|
data/Gemfile.lock
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
</div>
|
5
5
|
<div class="card-body">
|
6
6
|
<%= bootstrap_form_for @user, bootstrap_form: {} do |form| %>
|
7
|
-
<%= form.text_field :name, autocomplete: "new-name",
|
7
|
+
<%= form.text_field :name, autocomplete: "new-name", bootstrap_form: {} %>
|
8
8
|
<%= form.text_field :email, autocomplete: "new-email", bootstrap_form: {} %>
|
9
9
|
<%= form.text_field :password, autocomplete: "new-password" %>
|
10
10
|
<%= form.phone_field :mobile_number %>
|
@@ -12,8 +12,8 @@
|
|
12
12
|
<%= form.check_box :terms %>
|
13
13
|
<%= form.range_field :excellence %>
|
14
14
|
<%= form.url_field :blog_url %>
|
15
|
-
<%= form.
|
16
|
-
<%= form.select :fruit_id, options_for_select(::Fruit.pluck(:name, :id), form.object.fruit_id), include_blank: "Select Favorite Fruit" %>
|
15
|
+
<%= form.color_field :favorite_color %>
|
16
|
+
<%= form.select :fruit_id, options_for_select(::Fruit.pluck(:name, :id), form.object.fruit_id), {include_blank: "Select Favorite Fruit"} %>
|
17
17
|
<%= form.collection_check_boxes :skill_ids, ::Skill.all, :id, :name do |b| %>
|
18
18
|
<%= b.check_box + b.text %>
|
19
19
|
<% end %>
|
@@ -22,7 +22,7 @@
|
|
22
22
|
<%= address_form.text_field :state %>
|
23
23
|
<%= address_form.text_field :city %>
|
24
24
|
<%= address_form.text_field :postal_code %>
|
25
|
-
<%= address_form.select :country_id, options_for_select(::Country.pluck(:name, :id), address_form.object.country_id), {include_blank: "Select Country",
|
25
|
+
<%= address_form.select :country_id, options_for_select(::Country.pluck(:name, :id), address_form.object.country_id), {include_blank: "Select Country", bootstrap_form: {}} %>
|
26
26
|
<% end %>
|
27
27
|
<div class="mt-3">
|
28
28
|
<%= form.submit "Register", class: "btn btn-primary" %>
|
@@ -10,13 +10,17 @@ module RailsBootstrapForm
|
|
10
10
|
def input_group_wrapper(attribute, bootstrap_options, &block)
|
11
11
|
input = capture(&block) || ActiveSupport::SafeBuffer.new
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
if input_group_required?(bootstrap_options)
|
14
|
+
prepend = attach_input(bootstrap_options, :prepend)
|
15
|
+
append = attach_input(bootstrap_options, :append)
|
15
16
|
|
16
|
-
|
17
|
-
|
17
|
+
input = prepend + input + append
|
18
|
+
input += generate_error(attribute)
|
18
19
|
|
19
|
-
|
20
|
+
input = tag.div(input, class: input_group_classes(attribute, bootstrap_options))
|
21
|
+
else
|
22
|
+
input += generate_error(attribute)
|
23
|
+
end
|
20
24
|
|
21
25
|
input
|
22
26
|
end
|
@@ -42,8 +46,15 @@ module RailsBootstrapForm
|
|
42
46
|
tag.span(content.html_safe, class: "input-group-text")
|
43
47
|
end
|
44
48
|
|
49
|
+
def input_group_required?(bootstrap_options)
|
50
|
+
[
|
51
|
+
bootstrap_options.prepend,
|
52
|
+
bootstrap_options.append
|
53
|
+
].any?(&:present?)
|
54
|
+
end
|
55
|
+
|
45
56
|
private :input_group_wrapper, :input_group_classes, :attach_input,
|
46
|
-
:input_group_content
|
57
|
+
:input_group_content, :input_group_required?
|
47
58
|
end
|
48
59
|
end
|
49
60
|
end
|