comfy_bootstrap_form 4.0.8 → 4.0.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/README.md +4 -6
- data/lib/comfy_bootstrap_form/form_builder.rb +48 -2
- data/lib/comfy_bootstrap_form/version.rb +1 -1
- metadata +2 -3
- data/demo.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2199adf28ef935d5f2aabaac297c8e3efa9e064e6940a69c2ca47ca5048ce4f6
|
4
|
+
data.tar.gz: dd9e41ff96a4d230e40fbf1c7de45727303b092b57a8dfd2362d8105a00aa6a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6ca4fa7be726f57d96a37b72f1e679cce2a1b3720d2d355f7a9d61e9b7c7dba1294bcdd4be167ce00e2933578b4323d33f12dbc7a7d7ec84827cfd843fa8da5
|
7
|
+
data.tar.gz: 46018ae921efe5bf76a5233963c95ab27d8b3bc72ba924c233a5f9dfd9a155c6dc69ff473d526c4c08d38a4e27dcbdc315e5c8b5a61f6906cb83377d8e7cce49
|
data/README.md
CHANGED
@@ -98,13 +98,11 @@ date_field month_field range_field time_field
|
|
98
98
|
datetime_field number_field search_field url_field
|
99
99
|
email_field password_field text_area week_field
|
100
100
|
date_select time_select datetime_select
|
101
|
-
|
102
|
-
|
101
|
+
check_box radio_button rich_text_area
|
102
|
+
collection_check_boxes
|
103
|
+
collection_radio_buttons
|
103
104
|
```
|
104
105
|
|
105
|
-
Singular `radio_button` is not implemented as it doesn't make sense to wrap one
|
106
|
-
radio button input in Bootstrap markup.
|
107
|
-
|
108
106
|
#### Radio Buttons and Checkboxes
|
109
107
|
|
110
108
|
To render collection of radio buttons or checkboxes we use the same helper that
|
@@ -314,7 +312,7 @@ Feel free to take a look at the [Demo App](/demo) to see how everything renders.
|
|
314
312
|
Specifically see [form.html.erb](/demo/app/views/bootstrap/form.html.erb) template
|
315
313
|
for all kinds of different form configurations you can have.
|
316
314
|
|
317
|
-

|
315
|
+

|
318
316
|
|
319
317
|
---
|
320
318
|
|
@@ -123,6 +123,52 @@ module ComfyBootstrapForm
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
+
# Wrapper around radio button. Example usage:
|
127
|
+
#
|
128
|
+
# radio_button :choice, "value", bootstrap: {label: {text: "Do you agree?"}}
|
129
|
+
#
|
130
|
+
def radio_button(method, tag_value, options = {})
|
131
|
+
bootstrap = form_bootstrap.scoped(options.delete(:bootstrap))
|
132
|
+
return super if bootstrap.disabled
|
133
|
+
|
134
|
+
help_text = draw_help(bootstrap)
|
135
|
+
errors = draw_errors(bootstrap, method)
|
136
|
+
|
137
|
+
add_css_class!(options, "form-check-input")
|
138
|
+
add_css_class!(options, "is-invalid") if errors.present?
|
139
|
+
|
140
|
+
label_text = nil
|
141
|
+
if (custom_text = bootstrap.label[:text]).present?
|
142
|
+
label_text = custom_text
|
143
|
+
end
|
144
|
+
|
145
|
+
fieldset_css_class = "form-group"
|
146
|
+
fieldset_css_class += " row" if bootstrap.horizontal?
|
147
|
+
fieldset_css_class += " #{bootstrap.inline_margin_class}" if bootstrap.inline?
|
148
|
+
|
149
|
+
content_tag(:fieldset, class: fieldset_css_class) do
|
150
|
+
draw_control_column(bootstrap, offset: true) do
|
151
|
+
if bootstrap.custom_control
|
152
|
+
content_tag(:div, class: "custom-control custom-radio") do
|
153
|
+
add_css_class!(options, "custom-control-input")
|
154
|
+
remove_css_class!(options, "form-check-input")
|
155
|
+
concat super(method, tag_value, options)
|
156
|
+
concat label(method, label_text, value: tag_value, class: "custom-control-label")
|
157
|
+
concat errors if errors.present?
|
158
|
+
concat help_text if help_text.present?
|
159
|
+
end
|
160
|
+
else
|
161
|
+
content_tag(:div, class: "form-check") do
|
162
|
+
concat super(method, tag_value, options)
|
163
|
+
concat label(method, label_text, value: tag_value, class: "form-check-label")
|
164
|
+
concat errors if errors.present?
|
165
|
+
concat help_text if help_text.present?
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
126
172
|
# Wrapper around checkbox. Example usage:
|
127
173
|
#
|
128
174
|
# checkbox :agree, bootstrap: {label: {text: "Do you agree?"}}
|
@@ -186,7 +232,7 @@ module ComfyBootstrapForm
|
|
186
232
|
|
187
233
|
args = [bootstrap, :radio_button, method, collection, value_method, text_method, options, html_options]
|
188
234
|
draw_choices(*args) do |m, v, opts|
|
189
|
-
radio_button(m, v, opts)
|
235
|
+
radio_button(m, v, opts.merge(bootstrap: { disabled: true }))
|
190
236
|
end
|
191
237
|
end
|
192
238
|
|
@@ -208,7 +254,7 @@ module ComfyBootstrapForm
|
|
208
254
|
content << draw_choices(*args) do |m, v, opts|
|
209
255
|
opts[:multiple] = true
|
210
256
|
opts[:include_hidden] = false
|
211
|
-
|
257
|
+
check_box(m, opts.merge(bootstrap: { disabled: true }), v)
|
212
258
|
end
|
213
259
|
end
|
214
260
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comfy_bootstrap_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleg Khabarov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -41,7 +41,6 @@ files:
|
|
41
41
|
- README.md
|
42
42
|
- Rakefile
|
43
43
|
- comfy_bootstrap_form.gemspec
|
44
|
-
- demo.png
|
45
44
|
- lib/comfy_bootstrap_form.rb
|
46
45
|
- lib/comfy_bootstrap_form/bootstrap_options.rb
|
47
46
|
- lib/comfy_bootstrap_form/form_builder.rb
|
data/demo.png
DELETED
Binary file
|