comfy_bootstrap_form 4.0.4 → 4.0.5

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
- SHA1:
3
- metadata.gz: 52ad6eec307301d06755be3fbd82a3c62372be79
4
- data.tar.gz: 7b66272d0bea20d173bc39c64636c6fc79f3cb64
2
+ SHA256:
3
+ metadata.gz: 94e0f3c5edb6565a92ece2f975f82b925f8d4f8e58501fd169d182de470a1b66
4
+ data.tar.gz: 2e05af5a850dc55b3b1617434beef3f4b9818f58674dae4f2d9209f89eca6a3c
5
5
  SHA512:
6
- metadata.gz: 4b74b016d644a1fadfa212ba3abf1cd97be4d252d8b03813105aa22d20f013bf55529e5b5394f4b8750cf131d8e612b0373924e8134c30d0d58f553be3ac4192
7
- data.tar.gz: ce6aee4bef4cdb53e603c0d209c142f9f22955ed16d0036e83d76987728ece5758d5b8845d0f4ff564347acb922fc28af636c4a7309de1f43a4f686196e6855d
6
+ metadata.gz: c3556b0c99b48ad38115de529dd71aafe5f4ff39b5d8a988c6e366a55c3d79f809439652421220c0424663dcc5c74bdc2422d1f1e0de278bbc7db091feab7748
7
+ data.tar.gz: 3531e4156c12b989201d6b5cc332ff77944e81c04e3f4846f9eaf8effbdf47d2e25c4cc7fb29fa02330392291f57876c09b011378bd4fc25d6caa52f8a443007
data/README.md CHANGED
@@ -86,7 +86,7 @@ Wrapper around `form_for` helper that's available in all Rails 5 versions.
86
86
  Here's an example:
87
87
 
88
88
  ```erb
89
- <%= bootstrap_form_with @person, as: :user do |form| %>
89
+ <%= bootstrap_form_for @person, as: :user do |form| %>
90
90
  <%= form.email_field :email %>
91
91
  <%= form.submit %>
92
92
  <% end %>
@@ -295,6 +295,15 @@ radio buttons and file input field. Example usage:
295
295
  <%= form.collection_radio_buttons :choice, %w[yes no], :to_s, :to_s, bootstrap: {custom_control: true} %>
296
296
  ```
297
297
 
298
+ #### Disabling Bootstrap
299
+
300
+ You may completely disable bootstrap and use default form builder by passing
301
+ `disabled: true` option. For example:
302
+
303
+ ```erb
304
+ <%= form.text_field :username, bootstrap: {disabled: true} %>
305
+ ```
306
+
298
307
  ### Gotchas
299
308
 
300
309
  - In Rails 5.1 `form_with` does not generate ids for inputs. If you want them
@@ -11,10 +11,9 @@ Gem::Specification.new do |s|
11
11
  s.authors = ["Oleg Khabarov"]
12
12
  s.email = ["oleg@khabarov.ca"]
13
13
  s.homepage = "https://github.com/comfy/comfy-bootstrap-form"
14
- s.summary = "Rails form builder that makes it easy to style forms using "\
15
- "Bootstrap 4"
16
- s.description = "bootstrap_form is a rails form builder that makes it super "\
17
- "easy to create beautiful-looking forms using Bootstrap 4"
14
+ s.summary = "Rails form builder for Bootstrap 4 markup that actually works!"
15
+ s.description = "bootstrap_form is a Rails form builder that automatically wraps "\
16
+ "form elements in Bootstrap 4 markup"
18
17
  s.license = "MIT"
19
18
 
20
19
  s.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -11,6 +11,9 @@ module ComfyBootstrapForm
11
11
  #
12
12
  class BootstrapOptions
13
13
 
14
+ # When set to `true` only default rails form builder element is rendered.
15
+ attr_reader :disabled
16
+
14
17
  # Controls form layout. Can be: "vertical" (default), "horizontal" or "inline"
15
18
  attr_reader :layout
16
19
 
@@ -80,7 +83,7 @@ module ComfyBootstrapForm
80
83
  end
81
84
 
82
85
  def offset_col_class
83
- label_col_class.sub(%r{\Acol-(\w+)-(\d+)\z}, 'offset-\1-\2')
86
+ label_col_class.gsub(%r{col-(\w+)-(\d+)}, 'offset-\1-\2')
84
87
  end
85
88
 
86
89
  # This will return a copy of BootstrapOptions object with new options set
@@ -107,6 +110,7 @@ module ComfyBootstrapForm
107
110
  private
108
111
 
109
112
  def set_defaults
113
+ @disabled = false
110
114
  @layout = "vertical"
111
115
  @label_col_class = "col-sm-2"
112
116
  @control_col_class = "col-sm-10"
@@ -33,6 +33,7 @@ module ComfyBootstrapForm
33
33
  class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
34
34
  def #{field_helper}(method, options = {})
35
35
  bootstrap = form_bootstrap.scoped(options.delete(:bootstrap))
36
+ return super if bootstrap.disabled
36
37
  draw_form_group(bootstrap, method, options) do
37
38
  super(method, options)
38
39
  end
@@ -46,6 +47,7 @@ module ComfyBootstrapForm
46
47
  #
47
48
  def select(method, choices = nil, options = {}, html_options = {}, &block)
48
49
  bootstrap = form_bootstrap.scoped(options.delete(:bootstrap))
50
+ return super if bootstrap.disabled
49
51
 
50
52
  add_css_class!(html_options, "custom-select") if bootstrap.custom_control
51
53
 
@@ -60,6 +62,7 @@ module ComfyBootstrapForm
60
62
  #
61
63
  def file_field(method, options = {})
62
64
  bootstrap = form_bootstrap.scoped(options.delete(:bootstrap))
65
+ return super if bootstrap.disabled
63
66
 
64
67
  draw_form_group(bootstrap, method, options) do
65
68
  if bootstrap.custom_control
@@ -85,6 +88,7 @@ module ComfyBootstrapForm
85
88
  #
86
89
  def check_box(method, options = {}, checked_value = "1", unchecked_value = "0")
87
90
  bootstrap = form_bootstrap.scoped(options.delete(:bootstrap))
91
+ return super if bootstrap.disabled
88
92
 
89
93
  help_text = draw_help(bootstrap.help)
90
94
  errors = draw_errors(method)
@@ -137,6 +141,7 @@ module ComfyBootstrapForm
137
141
  #
138
142
  def collection_radio_buttons(method, collection, value_method, text_method, options = {}, html_options = {})
139
143
  bootstrap = form_bootstrap.scoped(options.delete(:bootstrap))
144
+ return super if bootstrap.disabled
140
145
 
141
146
  args = [bootstrap, :radio_button, method, collection, value_method, text_method, options, html_options]
142
147
  draw_choices(*args) do |m, v, opts|
@@ -151,6 +156,7 @@ module ComfyBootstrapForm
151
156
  #
152
157
  def collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {})
153
158
  bootstrap = form_bootstrap.scoped(options.delete(:bootstrap))
159
+ return super if bootstrap.disabled
154
160
 
155
161
  content = "".html_safe
156
162
  unless options[:include_hidden] == false
@@ -198,6 +204,7 @@ module ComfyBootstrapForm
198
204
  end
199
205
 
200
206
  bootstrap = form_bootstrap.scoped(options.delete(:bootstrap))
207
+ return super if bootstrap.disabled
201
208
 
202
209
  add_css_class!(options, "btn")
203
210
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ComfyBootstrapForm
4
4
 
5
- VERSION = "4.0.4"
5
+ VERSION = "4.0.5"
6
6
 
7
7
  end
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
4
+ version: 4.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Khabarov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-10 00:00:00.000000000 Z
11
+ date: 2018-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,8 +24,8 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 5.0.0
27
- description: bootstrap_form is a rails form builder that makes it super easy to create
28
- beautiful-looking forms using Bootstrap 4
27
+ description: bootstrap_form is a Rails form builder that automatically wraps form
28
+ elements in Bootstrap 4 markup
29
29
  email:
30
30
  - oleg@khabarov.ca
31
31
  executables: []
@@ -66,8 +66,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  version: '0'
67
67
  requirements: []
68
68
  rubyforge_project:
69
- rubygems_version: 2.6.14
69
+ rubygems_version: 2.7.6
70
70
  signing_key:
71
71
  specification_version: 4
72
- summary: Rails form builder that makes it easy to style forms using Bootstrap 4
72
+ summary: Rails form builder for Bootstrap 4 markup that actually works!
73
73
  test_files: []