rails_bootstrap_form 0.5.2 → 0.5.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/Gemfile.lock +1 -1
- data/demo/app/views/users/_vertical_form.html.erb +3 -3
- data/lib/rails_bootstrap_form/bootstrap_form_options.rb +16 -3
- data/lib/rails_bootstrap_form/components/check_box.rb +2 -1
- data/lib/rails_bootstrap_form/components/radio_button.rb +2 -1
- data/lib/rails_bootstrap_form/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1031de2aa81bb74657e9a45f334c4dc4d67ee673e89874358881d8021388d8b9
|
4
|
+
data.tar.gz: 4a5d3c85afb71bd06005eb95c0b8abb76a429a46ea49f22b470943bba2a6f7ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 188081d3651b5f6977df21c3bfb4436e44b3d96685ef8b6fc36b7805056b205ab77ced5f3ad4d3094217116e47f04e8a07a914db1f073c60be664bd4acf33694
|
7
|
+
data.tar.gz: 180295d5dbc0159f5181183be148203565d877d874d978074af43dd31ba0cfb7e7d8d2be3bcf3d3c72e1abe6d4ff58636da8c4386be3b09d64380edc4ef06b2d
|
data/Gemfile.lock
CHANGED
@@ -12,13 +12,13 @@
|
|
12
12
|
<%= form.check_box :terms, bootstrap_form: {switch: false}, required: true %>
|
13
13
|
<%= form.range_field :excellence %>
|
14
14
|
<%= form.url_field :blog_url %>
|
15
|
-
<%= form.collection_radio_buttons :fruit_id, ::Fruit.all, :id, :name, {bootstrap_form: {
|
15
|
+
<%= form.collection_radio_buttons :fruit_id, ::Fruit.all, :id, :name, {bootstrap_form: {inline: true}, checked: form.object.fruit_id} %>
|
16
16
|
<%= form.color_field :favorite_color %>
|
17
|
-
<%= form.collection_check_boxes :skill_ids, ::Skill.all, :id, :name, {bootstrap_form: {
|
17
|
+
<%= form.collection_check_boxes :skill_ids, ::Skill.all, :id, :name, {bootstrap_form: {inline: true}} %>
|
18
18
|
<%= form.fields_for :address, include_id: false do |address_form| %>
|
19
19
|
<%= address_form.text_area :street %>
|
20
20
|
<%= address_form.text_field :state %>
|
21
|
-
<%= address_form.grouped_collection_select :city, ::Country.
|
21
|
+
<%= address_form.grouped_collection_select :city, ::Country.includes(:cities), :cities, :name, :id, :name, {include_blank: "Select city"} %>
|
22
22
|
<%= address_form.text_field :postal_code %>
|
23
23
|
<%= address_form.select :country_id, options_for_select(::Country.pluck(:name, :id), address_form.object.country_id),
|
24
24
|
{include_blank: "Select Country", bootstrap_form: {}} %>
|
@@ -98,23 +98,34 @@ module RailsBootstrapForm
|
|
98
98
|
# The valid values are `sm` and `lg`. The default value is `nil`.
|
99
99
|
attr_accessor :size
|
100
100
|
|
101
|
+
# Option to render checkboxes and radio buttons inline.
|
102
|
+
# The default value if `false`.
|
103
|
+
#
|
104
|
+
# Example:
|
105
|
+
# form.collection_radio_buttons :choices, ["yes", "no"], :to_s, :to_s, bootstrap_form: {inline: true}
|
106
|
+
attr_accessor :inline
|
107
|
+
|
101
108
|
def initialize(options = {})
|
102
109
|
set_defaults
|
103
110
|
set_bootstrap_form_options(options)
|
104
111
|
end
|
105
112
|
|
106
|
-
def
|
113
|
+
def layout_horizontal?
|
107
114
|
@layout.to_s == "horizontal"
|
108
115
|
end
|
109
116
|
|
110
|
-
def
|
117
|
+
def layout_inline?
|
111
118
|
@layout.to_s == "inline"
|
112
119
|
end
|
113
120
|
|
114
|
-
def
|
121
|
+
def layout_vertical?
|
115
122
|
@layout.to_s == "vertical"
|
116
123
|
end
|
117
124
|
|
125
|
+
def inline?
|
126
|
+
self.inline
|
127
|
+
end
|
128
|
+
|
118
129
|
# This will return a copy of `BootstrapFormOptions` object with new options set
|
119
130
|
# that don't affect original object. This way we can have options specific
|
120
131
|
# to a given form field. For example, we can change grid just for one field:
|
@@ -160,6 +171,8 @@ module RailsBootstrapForm
|
|
160
171
|
@wrapper_options = {}
|
161
172
|
|
162
173
|
@size = nil
|
174
|
+
|
175
|
+
@inline = false
|
163
176
|
end
|
164
177
|
|
165
178
|
private :set_defaults
|
@@ -61,7 +61,8 @@ module RailsBootstrapForm
|
|
61
61
|
def check_box_wrapper_class(bootstrap_options)
|
62
62
|
classes = Array("form-check")
|
63
63
|
classes << "form-switch" if bootstrap_options.switch
|
64
|
-
classes <<
|
64
|
+
classes << "form-check-inline" if bootstrap_options.inline?
|
65
|
+
classes << "mb-3"
|
65
66
|
classes.flatten.compact
|
66
67
|
end
|
67
68
|
|
@@ -57,7 +57,8 @@ module RailsBootstrapForm
|
|
57
57
|
|
58
58
|
def radio_button_wrapper_class(bootstrap_options)
|
59
59
|
classes = Array("form-check")
|
60
|
-
classes <<
|
60
|
+
classes << "form-check-inline" if bootstrap_options.inline?
|
61
|
+
classes << "mb-3"
|
61
62
|
classes.flatten.compact
|
62
63
|
end
|
63
64
|
|