rails_bootstrap_form 0.9.4 → 0.9.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 +4 -4
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +1 -1
- data/README.md +6 -4
- data/lib/rails_bootstrap_form/bootstrap_form_options.rb +10 -2
- data/lib/rails_bootstrap_form/field_wrapper_builder.rb +1 -1
- data/lib/rails_bootstrap_form/inputs/base.rb +6 -3
- data/lib/rails_bootstrap_form/inputs/collection_check_boxes.rb +2 -1
- data/lib/rails_bootstrap_form/inputs/collection_radio_buttons.rb +2 -1
- data/lib/rails_bootstrap_form/inputs/collection_select.rb +2 -2
- data/lib/rails_bootstrap_form/inputs/color_field.rb +3 -7
- data/lib/rails_bootstrap_form/inputs/grouped_collection_select.rb +2 -2
- data/lib/rails_bootstrap_form/inputs/range_field.rb +3 -2
- data/lib/rails_bootstrap_form/inputs/rich_text_area.rb +1 -1
- data/lib/rails_bootstrap_form/inputs/select.rb +2 -2
- data/lib/rails_bootstrap_form/inputs/static_field.rb +10 -12
- data/lib/rails_bootstrap_form/inputs/time_zone_select.rb +2 -2
- data/lib/rails_bootstrap_form/inputs/weekday_select.rb +2 -2
- data/lib/rails_bootstrap_form/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f852149d96066acbbb48afc05ba8dd6d11f535401e9cdff2e6535829f9669303
|
4
|
+
data.tar.gz: d322c72387d0933048e789d849dfe79f9ee7c23f46b8eb2872d349e7698a1008
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33a938a56a607b29bccd8c5ef712a68d7cd3caee5486b6002a8783023779222f211396d47ffa9e7aaf392820acd22e26d5d20a72c9e765a5aceec07355a34525
|
7
|
+
data.tar.gz: 1418938ffaadcf8a58439324e844f3acff4f437f07ff58e14df45eafb539c35211a28f567b1e3d6409b1e14c7667d62bbd650c7d8f90ea6fa5ba99fc3a37ea66
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,18 @@ You can find recent releases with docs in GitHub:
|
|
4
4
|
|
5
5
|
https://github.com/shivam091/rails_bootstrap_form/releases
|
6
6
|
|
7
|
+
## [0.9.4](https://github.com/shivam091/rails_bootstrap_form/compare/v0.9.4...v0.9.5) - 2023-06-21
|
8
|
+
|
9
|
+
### What's changed
|
10
|
+
|
11
|
+
- Changed default value of `field_class` option to `nil`.
|
12
|
+
|
13
|
+
### What's fixed
|
14
|
+
|
15
|
+
- Fixed static field options to accept bootstrap options ([#45](https://github.com/shivam091/rails_bootstrap_form/issues/45))
|
16
|
+
- Changes to allow overriding of field_class at form and field level ([#44](https://github.com/shivam091/rails_bootstrap_form/issues/44))
|
17
|
+
- Fixed bug causing class attribute in select list to not get added to field ([#46](https://github.com/shivam091/rails_bootstrap_form/issues/46))
|
18
|
+
|
7
19
|
## [0.9.4](https://github.com/shivam091/rails_bootstrap_form/compare/v0.9.3...v0.9.4) - 2023-06-17
|
8
20
|
|
9
21
|
### What's new
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -28,7 +28,7 @@ for setting up `application.scss` and `application.js`.
|
|
28
28
|
Add the `rails_bootstrap_form` gem to your `Gemfile`:
|
29
29
|
|
30
30
|
```ruby
|
31
|
-
gem "rails_bootstrap_form", "~> 0.9.
|
31
|
+
gem "rails_bootstrap_form", "~> 0.9.5"
|
32
32
|
```
|
33
33
|
|
34
34
|
Then:
|
@@ -154,13 +154,13 @@ This generates the following HTML:
|
|
154
154
|
|
155
155
|
## Bootstrap Configuration Options
|
156
156
|
|
157
|
-
Here's a list of all possible options you can pass via `bootstrap` option that can be attached to the `bootstrap_form_for
|
157
|
+
Here's a list of all possible options you can pass via `bootstrap` option that can be attached to the `bootstrap_form_for`, `bootstrap_form_with`, `fields_for`, or any field helpers inside of it:
|
158
158
|
|
159
159
|
| Option | Description | Default value |
|
160
160
|
| ------ | ------------- | ----------- |
|
161
161
|
| `disabled` | An option to disable **rails_bootstrap_form** helpers. Default rails form builder element is rendered when set to `true` | `false` |
|
162
162
|
| `layout` | Controls layout of form and field helpers. It can be `vertical` `horizontal`, or `inline`. | `vertical` |
|
163
|
-
| `field_class` | A CSS class that will be applied to all form fields. | `
|
163
|
+
| `field_class` | A CSS class that will be applied to all form fields. | `nil` |
|
164
164
|
| `help_text` | Describes help text for the HTML field. Help text is automatically read from translation file. If you want to customize it, you can pass a string. You can also set it `false` if you do not want help text displayed. | `nil` |
|
165
165
|
| `label_text` | An option to customize automatically generated label text. | `nil` |
|
166
166
|
| `skip_label` | An option to control whether the label is to be displayed or not. | `false` |
|
@@ -322,7 +322,7 @@ time_field time_select time_zone_select
|
|
322
322
|
url_field week_field weekday_select
|
323
323
|
```
|
324
324
|
|
325
|
-
## Supported
|
325
|
+
## Supported Form Layouts
|
326
326
|
|
327
327
|
### Vertical Layout
|
328
328
|
|
@@ -1030,6 +1030,8 @@ This generates the following HTML:
|
|
1030
1030
|
</form>
|
1031
1031
|
```
|
1032
1032
|
|
1033
|
+
Options specified at the field level take precedence over those specified at the fields_for level, which take precedence over those specified at the form level.
|
1034
|
+
|
1033
1035
|
### file_field
|
1034
1036
|
|
1035
1037
|
Our `file_field` helper accepts the same arguments as the [default Rails helper](https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-file_field).
|
@@ -25,7 +25,7 @@ module RailsBootstrapForm
|
|
25
25
|
attr_accessor :layout
|
26
26
|
|
27
27
|
# A CSS class that will be applied to all form fields.
|
28
|
-
# The default value is `
|
28
|
+
# The default value is `nil`.
|
29
29
|
attr_accessor :field_class
|
30
30
|
|
31
31
|
# An additional CSS class that will be added along with the existing
|
@@ -169,12 +169,20 @@ module RailsBootstrapForm
|
|
169
169
|
define_method("#{method}?") { self.send(method) }
|
170
170
|
end
|
171
171
|
|
172
|
+
def disable_floating_labels!
|
173
|
+
self.floating = false
|
174
|
+
end
|
175
|
+
|
176
|
+
def set_field_class!(css_class)
|
177
|
+
self.field_class ||= css_class
|
178
|
+
end
|
179
|
+
|
172
180
|
def set_defaults
|
173
181
|
@disabled = false
|
174
182
|
|
175
183
|
@layout = "vertical"
|
176
184
|
|
177
|
-
@field_class =
|
185
|
+
@field_class = nil
|
178
186
|
@additional_field_class = nil
|
179
187
|
|
180
188
|
@help_text = nil
|
@@ -72,7 +72,7 @@ module RailsBootstrapForm
|
|
72
72
|
def field_css_options(attribute, bootstrap, options, html_options)
|
73
73
|
css_options = (html_options || options)
|
74
74
|
|
75
|
-
field_classes = Array(bootstrap.field_class) << [bootstrap.additional_field_class ||
|
75
|
+
field_classes = Array(bootstrap.field_class) << [bootstrap.additional_field_class || css_options[:class]]
|
76
76
|
field_classes << "is-invalid" if is_invalid?(attribute)
|
77
77
|
if is_size_valid?(bootstrap)
|
78
78
|
field_classes << "#{bootstrap.field_class}-#{bootstrap.size}"
|
@@ -17,7 +17,7 @@ module RailsBootstrapForm
|
|
17
17
|
input_options = {
|
18
18
|
bootstrap: {
|
19
19
|
label_text: text_method.respond_to?(:call) ? text_method.call(object) : object.send(text_method),
|
20
|
-
inline: (bootstrap.inline? || bootstrap.layout_inline?)
|
20
|
+
inline: (bootstrap.inline? || bootstrap.layout_inline?)
|
21
21
|
},
|
22
22
|
required: false,
|
23
23
|
id: sanitized_tag_name(attribute, value)
|
@@ -42,6 +42,8 @@ module RailsBootstrapForm
|
|
42
42
|
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
43
43
|
return super(attribute, options) if bootstrap.disabled?
|
44
44
|
|
45
|
+
bootstrap.set_field_class!("form-control")
|
46
|
+
|
45
47
|
field_wrapper_builder(attribute, bootstrap, options) do
|
46
48
|
super(attribute, options)
|
47
49
|
end
|
@@ -50,11 +52,12 @@ module RailsBootstrapForm
|
|
50
52
|
|
51
53
|
def bootstrap_select_group(tag_name)
|
52
54
|
define_method(tag_name) do |attribute, options = {}, html_options = {}|
|
53
|
-
options = {bootstrap: {field_class: "form-select", floating: false}}.deep_merge!(options)
|
54
|
-
|
55
55
|
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
56
56
|
return super(attribute, options, html_options) if bootstrap.disabled?
|
57
57
|
|
58
|
+
bootstrap.set_field_class!("form-select")
|
59
|
+
bootstrap.disable_floating_labels!
|
60
|
+
|
58
61
|
field_wrapper_builder(attribute, bootstrap, options, html_options) do
|
59
62
|
tag.fieldset(class: control_specific_class(tag_name)) do
|
60
63
|
super(attribute, options, html_options)
|
@@ -10,9 +10,10 @@ module RailsBootstrapForm
|
|
10
10
|
included do
|
11
11
|
def collection_check_boxes(attribute, collection, value_method, text_method, options = {}, html_options = {})
|
12
12
|
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
13
|
-
bootstrap.floating = false
|
14
13
|
return super if bootstrap.disabled?
|
15
14
|
|
15
|
+
bootstrap.disable_floating_labels!
|
16
|
+
|
16
17
|
inputs = inputs_collection(attribute, collection, value_method, text_method, bootstrap, options) do |attribute, value, options|
|
17
18
|
bootstrap_opts = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
18
19
|
|
@@ -10,9 +10,10 @@ module RailsBootstrapForm
|
|
10
10
|
included do
|
11
11
|
def collection_radio_buttons(attribute, collection, value_method, text_method, options = {}, html_options = {})
|
12
12
|
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
13
|
-
bootstrap.floating = false
|
14
13
|
return super if bootstrap.disabled?
|
15
14
|
|
15
|
+
bootstrap.disable_floating_labels!
|
16
|
+
|
16
17
|
inputs = inputs_collection(attribute, collection, value_method, text_method, bootstrap, options) do |attribute, value, options|
|
17
18
|
bootstrap_opts = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
18
19
|
|
@@ -9,11 +9,11 @@ module RailsBootstrapForm
|
|
9
9
|
|
10
10
|
included do
|
11
11
|
def collection_select(attribute, collection, value_method, text_method, options = {}, html_options = {})
|
12
|
-
options = {bootstrap: {field_class: "form-select"}}.deep_merge!(options)
|
13
|
-
|
14
12
|
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
15
13
|
return super if bootstrap.disabled?
|
16
14
|
|
15
|
+
bootstrap.set_field_class!("form-select")
|
16
|
+
|
17
17
|
field_wrapper_builder(attribute, bootstrap, options, html_options) do
|
18
18
|
super(attribute, collection, value_method, text_method, options, html_options)
|
19
19
|
end
|
@@ -9,16 +9,12 @@ module RailsBootstrapForm
|
|
9
9
|
|
10
10
|
included do
|
11
11
|
def color_field(attribute, options = {})
|
12
|
-
options = {
|
13
|
-
bootstrap: {
|
14
|
-
field_class: "form-control form-control-color",
|
15
|
-
floating: false
|
16
|
-
}
|
17
|
-
}.deep_merge!(options)
|
18
|
-
|
19
12
|
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
20
13
|
return super if bootstrap.disabled?
|
21
14
|
|
15
|
+
bootstrap.set_field_class!("form-control form-control-color")
|
16
|
+
bootstrap.disable_floating_labels!
|
17
|
+
|
22
18
|
field_wrapper_builder(attribute, bootstrap, options) do
|
23
19
|
super(attribute, options)
|
24
20
|
end
|
@@ -9,11 +9,11 @@ module RailsBootstrapForm
|
|
9
9
|
|
10
10
|
included do
|
11
11
|
def grouped_collection_select(attribute, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {})
|
12
|
-
options = {bootstrap: {field_class: "form-select"}}.deep_merge!(options)
|
13
|
-
|
14
12
|
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
15
13
|
return super if bootstrap.disabled?
|
16
14
|
|
15
|
+
bootstrap.set_field_class!("form-select")
|
16
|
+
|
17
17
|
field_wrapper_builder(attribute, bootstrap, options, html_options) do
|
18
18
|
super(attribute, collection, group_method, group_label_method, option_key_method, option_value_method, options, html_options)
|
19
19
|
end
|
@@ -9,11 +9,12 @@ module RailsBootstrapForm
|
|
9
9
|
|
10
10
|
included do
|
11
11
|
def range_field(attribute, options = {})
|
12
|
-
options = {bootstrap: {field_class: "form-range", floating: false}}.deep_merge!(options)
|
13
|
-
|
14
12
|
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
15
13
|
return super if bootstrap.disabled?
|
16
14
|
|
15
|
+
bootstrap.set_field_class!("form-range")
|
16
|
+
bootstrap.disable_floating_labels!
|
17
|
+
|
17
18
|
field_wrapper_builder(attribute, bootstrap, options) do
|
18
19
|
super(attribute, options)
|
19
20
|
end
|
@@ -9,7 +9,7 @@ module RailsBootstrapForm
|
|
9
9
|
|
10
10
|
included do
|
11
11
|
def rich_text_area(attribute, options = {})
|
12
|
-
options
|
12
|
+
add_css_class!(options, "trix-content")
|
13
13
|
|
14
14
|
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
15
15
|
return super if bootstrap.disabled?
|
@@ -9,11 +9,11 @@ module RailsBootstrapForm
|
|
9
9
|
|
10
10
|
included do
|
11
11
|
def select(attribute, choices = nil, options = {}, html_options = {}, &block)
|
12
|
-
options = {bootstrap: {field_class: "form-select"}}.deep_merge!(options)
|
13
|
-
|
14
12
|
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
15
13
|
return super if bootstrap.disabled?
|
16
14
|
|
15
|
+
bootstrap.set_field_class!("form-select")
|
16
|
+
|
17
17
|
field_wrapper_builder(attribute, bootstrap, options, html_options) do
|
18
18
|
super(attribute, choices, options, html_options, &block)
|
19
19
|
end
|
@@ -8,21 +8,19 @@ module RailsBootstrapForm
|
|
8
8
|
extend ActiveSupport::Concern
|
9
9
|
|
10
10
|
included do
|
11
|
-
def static_field(
|
12
|
-
options
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
disabled: true,
|
18
|
-
bootstrap: {
|
11
|
+
def static_field(attribute, options = {})
|
12
|
+
options.tap do |option|
|
13
|
+
option[:readonly] = true
|
14
|
+
option[:disabled] = true
|
15
|
+
option[:bootstrap] = {
|
16
|
+
floating: false,
|
19
17
|
field_class: bootstrap_form_options.static_field_class
|
20
|
-
}.reverse_merge!(options.
|
21
|
-
|
18
|
+
}.reverse_merge!(options.fetch(:bootstrap, {}))
|
19
|
+
end
|
22
20
|
|
23
|
-
|
21
|
+
options[:value] = object.send(attribute) unless options.key?(:value)
|
24
22
|
|
25
|
-
text_field(attribute,
|
23
|
+
text_field(attribute, options)
|
26
24
|
end
|
27
25
|
end
|
28
26
|
end
|
@@ -9,11 +9,11 @@ module RailsBootstrapForm
|
|
9
9
|
|
10
10
|
included do
|
11
11
|
def time_zone_select(attribute, priority_zones = nil, options = {}, html_options = {})
|
12
|
-
options = {bootstrap: {field_class: "form-select"}}.deep_merge!(options)
|
13
|
-
|
14
12
|
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
15
13
|
return super if bootstrap.disabled?
|
16
14
|
|
15
|
+
bootstrap.set_field_class!("form-select")
|
16
|
+
|
17
17
|
field_wrapper_builder(attribute, bootstrap, options, html_options) do
|
18
18
|
super(attribute, priority_zones, options, html_options)
|
19
19
|
end
|
@@ -9,11 +9,11 @@ module RailsBootstrapForm
|
|
9
9
|
|
10
10
|
included do
|
11
11
|
def weekday_select(attribute, options = {}, html_options = {}, &block)
|
12
|
-
options = {bootstrap: {field_class: "form-select"}}.deep_merge!(options)
|
13
|
-
|
14
12
|
bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
|
15
13
|
return super if bootstrap.disabled?
|
16
14
|
|
15
|
+
bootstrap.set_field_class!("form-select")
|
16
|
+
|
17
17
|
field_wrapper_builder(attribute, bootstrap, options, html_options) do
|
18
18
|
super(attribute, options, html_options, &block)
|
19
19
|
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.5
|
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-06-
|
11
|
+
date: 2023-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: generator_spec
|