rails_bootstrap_form 0.9.3 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8bb2a8a391176d2d0e578b3ce1591c6f1f996cc8f5ebbb1ad6fcaddf9087be7e
4
- data.tar.gz: a995a9c68d6509edc9f3327674783fb85c831f0107e269fc1ffbd75b98438b04
3
+ metadata.gz: f852149d96066acbbb48afc05ba8dd6d11f535401e9cdff2e6535829f9669303
4
+ data.tar.gz: d322c72387d0933048e789d849dfe79f9ee7c23f46b8eb2872d349e7698a1008
5
5
  SHA512:
6
- metadata.gz: 62c3811ebcb7356b7e5333c48146f2f2958aa16ecefc71cd7c9a05dcb1bafac659d019484e26a1bb5b0e901d1cbc041b9d88509816cb270a6ceb11a870252a12
7
- data.tar.gz: d395785a7267dd780584e0ca968faf265e9ca5d637e206d66fa46a7c77da69b71314ae397b02a5a8b6e4bb6cb1cbc79dfcecf62ddbc11b2951af733668ee2a8e
6
+ metadata.gz: 33a938a56a607b29bccd8c5ef712a68d7cd3caee5486b6002a8783023779222f211396d47ffa9e7aaf392820acd22e26d5d20a72c9e765a5aceec07355a34525
7
+ data.tar.gz: 1418938ffaadcf8a58439324e844f3acff4f437f07ff58e14df45eafb539c35211a28f567b1e3d6409b1e14c7667d62bbd650c7d8f90ea6fa5ba99fc3a37ea66
data/CHANGELOG.md CHANGED
@@ -4,6 +4,36 @@ 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
+
19
+ ## [0.9.4](https://github.com/shivam091/rails_bootstrap_form/compare/v0.9.3...v0.9.4) - 2023-06-17
20
+
21
+ ### What's new
22
+
23
+ - Added specs for field helpers.
24
+
25
+ ### What's changed
26
+
27
+ - Change to take `additional_field_class` precedence over HTML `class` ([#42](https://github.com/shivam091/rails_bootstrap_form/issues/42))
28
+ - Change to `collection_check_boxes` and `collection_radio buttons` to render inline `check boxes` and
29
+ `radio buttons`, respectively when form layout is inline. ([#43](https://github.com/shivam091/rails_bootstrap_form/issues/43))
30
+
31
+ ### What's fixed
32
+
33
+ - Fixed bug causing `skip_label` option not to work in `radio_button` and `check_box` ([#37](https://github.com/shivam091/rails_bootstrap_form/issues/37))
34
+ - Fixed bug causing `additional_field_class` to apply on `radio_button` and `check_box` ([#40](https://github.com/shivam091/rails_bootstrap_form/issues/40))
35
+ - Fixed bug causing `bootstrap` options to not set on `static_field` ([#41](https://github.com/shivam091/rails_bootstrap_form/issues/41))
36
+
7
37
  ## [0.9.3](https://github.com/shivam091/rails_bootstrap_form/compare/v0.9.2...v0.9.3) - 2023-06-04
8
38
 
9
39
  ### What's changed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_bootstrap_form (0.9.3)
4
+ rails_bootstrap_form (0.9.5)
5
5
  actionpack (~> 7.0)
6
6
  activemodel (~> 7.0)
7
7
 
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Gem Version](https://badge.fury.io/rb/rails_bootstrap_form.svg)](https://badge.fury.io/rb/rails_bootstrap_form)
5
5
 
6
6
  **rails_bootstrap_form** is a Rails form builder that makes it super easy to integrate [Bootstrap 5](https://getbootstrap.com/) forms into your Rails application.
7
- `rails_bootstrap_forms`'s form helpers generate the form field and its label along with all the Bootstrap mark-up required for proper Bootstrap display.
7
+ `rails_bootstrap_form`'s form helpers generate the form field and its label along with all the Bootstrap mark-up required for proper Bootstrap display.
8
8
 
9
9
  ## Minimum Requirements
10
10
 
@@ -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.8.2"
31
+ gem "rails_bootstrap_form", "~> 0.9.5"
32
32
  ```
33
33
 
34
34
  Then:
@@ -64,7 +64,7 @@ Example:
64
64
  # config/initializers/rails_bootstrap_form.rb
65
65
  RailsBootstrapForm.configure do |config|
66
66
  # to make forms non-compliant with W3C.
67
- config.default_form_attributes = {role: "form", novalidate: true}
67
+ config.default_form_attributes = {novalidate: true}
68
68
  end
69
69
  ```
70
70
 
@@ -72,7 +72,7 @@ The current configuration options are:
72
72
 
73
73
  | Option | Default value | Description |
74
74
  |---------------------------|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
75
- | `default_form_attributes` | | Set this option to `{role: "form"}` to make forms non-compliant with W3C, but generate the `role="form"` attribute. |
75
+ | `default_form_attributes` | | Set this option to `{novalidate: true}` to instruct `rails_bootstrap_form` to skip all HTML 5 validation. |
76
76
 
77
77
  ## Usage
78
78
 
@@ -154,14 +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` or `bootstrap_form_with` or any field helpers inside of it:
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. | `form-control` |
164
- | `additional_field_class` | An additional CSS class that will be added along with the existing css classes of field helpers. | `nil` |
163
+ | `field_class` | A CSS class that will be applied to all form fields. | `nil` |
165
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` |
166
165
  | `label_text` | An option to customize automatically generated label text. | `nil` |
167
166
  | `skip_label` | An option to control whether the label is to be displayed or not. | `false` |
@@ -183,7 +182,7 @@ Here's a list of all possible options you can pass via `bootstrap` option that c
183
182
  | `field_col_wrapper_class` | A CSS class for field column when layout is `horizontal`. | `col-sm-10` |
184
183
  | `render_as_button` | An option to render submit button using `<button type="submit">` instead of `<input type="submit">`. | `false` |
185
184
 
186
- Options applied on the form level will apply to all field helpers. Options applied on field helpers will override form-level options.
185
+ Options defined on the form level will apply to all field helpers. Options defined on field helpers takes precedence over form-level options.
187
186
  Here's an example of a form where one field uses different layout:
188
187
 
189
188
  ![bootstrap_option_override](https://github.com/shivam091/rails_bootstrap_form/assets/7858927/9d312870-033f-4bc4-922b-1b65df202352)
@@ -235,9 +234,15 @@ You can completely disable bootstrap and use default form builder by passing `di
235
234
  <%= form.text_field :username, bootstrap: {disabled: true} %>
236
235
  ```
237
236
 
237
+ This generates the following HTML:
238
+
239
+ ```html
240
+ <input type="text" name="user[username]" id="user_username">
241
+ ```
242
+
238
243
  ### Disabling wrapper
239
244
 
240
- In some cases, you may need to disable the default wrapper. You can do this by passing 'wrapper: false':
245
+ In some cases, you may need to disable the default wrapper. You can do this by passing `wrapper: false` option:
241
246
 
242
247
  ![wrapper_false](https://github.com/shivam091/rails_bootstrap_form/assets/7858927/1693cf0f-7a30-494d-9fb5-394f4fb2c676)
243
248
 
@@ -252,6 +257,53 @@ This generates the following HTML:
252
257
  <input class="form-control" aria-required="true" required="required" type="text" name="user[name]" id="user_name">
253
258
  ```
254
259
 
260
+ ### Add additional CSS class
261
+
262
+ You can use `additional_field_class` option at form or field level to add extra CSS classes to the fields.
263
+
264
+ ```erb
265
+ <%= form.text_field :name, autocomplete: "new-name", bootstrap: {additional_field_class: "custom-class"} %>
266
+ ```
267
+
268
+ This generates the following HTML:
269
+
270
+ ```html
271
+ <div class="mb-3">
272
+ <label class="form-label required" for="user_name">Name</label>
273
+ <input autocomplete="new-name" class="form-control custom-class" aria-required="true" required="required" type="text" name="user[name]" id="user_name">
274
+ </div>
275
+ ```
276
+
277
+ You can also use HTML `class` attribute to add additional CSS class to the single field:
278
+
279
+ ```erb
280
+ <%= form.text_field :name, autocomplete: "new-name", class: "custom-class" %>
281
+ ```
282
+
283
+ This generates the following HTML:
284
+
285
+ ```html
286
+ <div class="mb-3">
287
+ <label class="form-label required" for="user_name">Name</label>
288
+ <input autocomplete="new-name" class="form-control custom-class" aria-required="true" required="required" type="text" name="user[name]" id="user_name">
289
+ </div>
290
+ ```
291
+
292
+ Here `additional_field_class` option takes precedance over HTML `class` attribute:
293
+
294
+ ```erb
295
+ <%= form.text_field :name, autocomplete: "new-name", bootstrap: {additional_field_class: "custom-class"}, class: "html-class" %>
296
+ ```
297
+
298
+ This generates the following HTML:
299
+
300
+ ```html
301
+ <div class="mb-3">
302
+ <label class="form-label required" for="user_name">Name</label>
303
+ <input autocomplete="new-name" class="form-control custom-class" aria-required="true" required="required" type="text" name="user[name]" id="user_name">
304
+ </div>
305
+ ```
306
+
255
307
  ## Supported Form Helpers
256
308
 
257
309
  This gem wraps most of the form field helpers. Here's the current list:
@@ -270,11 +322,11 @@ time_field time_select time_zone_select
270
322
  url_field week_field weekday_select
271
323
  ```
272
324
 
273
- ## Supported form layouts
325
+ ## Supported Form Layouts
274
326
 
275
327
  ### Vertical Layout
276
328
 
277
- This layout is default layout for the form in which labels are above the fields and labels and fields take 100% of the width.
329
+ This layout is default layout for the form in which labels are above the fields. In this layout, labels and fields take 100% of the width.
278
330
 
279
331
  Here's an example of how it looks like:
280
332
 
@@ -308,7 +360,7 @@ This generates the following HTML:
308
360
 
309
361
  If you want to align label and field side by side, you can use horizontal layout for the form.
310
362
  You can optionally override `label_col_wrapper_class` and `field_col_wrapper_class` (they default to `col-sm-2` and `col-sm-10`) at either form level
311
- or field helpers if want to customize space between label and field.
363
+ or field level if want to customize space between label and field.
312
364
 
313
365
  Here's an example of how it looks like by default:
314
366
 
@@ -341,7 +393,7 @@ This generates the following HTML:
341
393
  </form>
342
394
  ```
343
395
 
344
- The `label_col_wrapper_class` and `field_col_wrapper_class` css classes can also be changed per control:
396
+ The `label_col_wrapper_class` and `field_col_wrapper_class` css classes can also be customized per control:
345
397
 
346
398
  ![horizontal_form_custom_classes](https://github.com/shivam091/rails_bootstrap_form/assets/7858927/ae5492f0-4a10-4f63-ae4d-9675bfb93226)
347
399
 
@@ -454,7 +506,7 @@ This generates the following HTML:
454
506
  </div>
455
507
  ```
456
508
 
457
- To hide a label, you can set `hide_label` option to `true`. This adds the `visually-hidden` class, which keeps your labels accessible
509
+ To hide a label, you can set `hide_label: true` option. This adds the `visually-hidden` class, which keeps your labels accessible
458
510
  to those using screen readers.
459
511
 
460
512
  ![hide_label](https://github.com/shivam091/rails_bootstrap_form/assets/7858927/512a16b9-6829-40a2-bf07-f087970c9dac)
@@ -472,7 +524,7 @@ This generates the following HTML:
472
524
  </div>
473
525
  ```
474
526
 
475
- To skip a label, you can set `skip_label` option to `true`. This will not render label in a field wrapper.
527
+ To skip a label, you can set `skip_label: true` option. This will not render label in a field wrapper.
476
528
 
477
529
  ![skip_label](https://github.com/shivam091/rails_bootstrap_form/assets/7858927/251e28ac-b98b-4e6a-8d55-8c0cb061e65a)
478
530
 
@@ -552,7 +604,7 @@ This generates the following HTML:
552
604
  </div>
553
605
  ```
554
606
 
555
- You can also disable help text by setting `help_text` option to `false`:
607
+ You can also disable help text by setting `help_text: false` option:
556
608
 
557
609
  ![help_text_false](https://github.com/shivam091/rails_bootstrap_form/assets/7858927/be1a229a-cffd-447d-b846-9b9588b1b25e)
558
610
 
@@ -707,7 +759,7 @@ This generates the following HTML:
707
759
  </div>
708
760
  ```
709
761
 
710
- You can set `switch` option to `true` if you want check box to look like switches.
762
+ You can set `switch: true` option if you want check box to look like switches.
711
763
 
712
764
  ![check_box_switch](https://github.com/shivam091/rails_bootstrap_form/assets/7858927/20c493ce-7f2c-4ac9-a854-e1520cae6a54)
713
765
 
@@ -845,7 +897,7 @@ This generates the following HTML:
845
897
 
846
898
  Our `fields_for` helper accepts the same arguments as the [default Rails helper](https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-fields_for).
847
899
 
848
- `rails_bootstrap_form` allows us to set `bootstrap` option just like `bootstrap_form_for` and `bootstrap_form_with`. By setting this option on fields_for, it applies to all the fields defined for that form:
900
+ `rails_bootstrap_form` allows us to set `bootstrap` option just like `bootstrap_form_for` and `bootstrap_form_with`. By setting this option on `fields_for`, it applies to all the fields defined for that nested form:
849
901
 
850
902
  ![fields_for](https://github.com/shivam091/rails_bootstrap_form/assets/7858927/f515302f-a92a-4b5c-a444-af91cbb00dff)
851
903
 
@@ -978,6 +1030,8 @@ This generates the following HTML:
978
1030
  </form>
979
1031
  ```
980
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
+
981
1035
  ### file_field
982
1036
 
983
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).
@@ -1441,7 +1495,7 @@ an argument and takes care of rendering labels, check boxes, and wrapper for you
1441
1495
  ![collection_check_boxes](https://github.com/shivam091/rails_bootstrap_form/assets/7858927/c92f5921-e572-4384-812e-31308e018f66)
1442
1496
 
1443
1497
  ```erb
1444
- <%= form.collection_check_boxes :skill_ids, ::Skill.all, :id, :name, {bootstrap: {layout: :horizontal, inline: true}, onchange: "this.form.submit();"}, {} %>
1498
+ <%= form.collection_check_boxes :skill_ids, ::Skill.all, :id, :name, {multiple: true, bootstrap: {layout: :horizontal, inline: true}, onchange: "this.form.submit();"}, {} %>
1445
1499
  ```
1446
1500
 
1447
1501
  This generates the following HTML:
@@ -1498,6 +1552,8 @@ This generates the following HTML:
1498
1552
  </div>
1499
1553
  ```
1500
1554
 
1555
+ _If form layout is inline, `collection_check_boxes` always render `inline` check boxes._
1556
+
1501
1557
  ### collection_radio_buttons
1502
1558
 
1503
1559
  This helper provides a way to create collection of radio buttons. This helper accepts same arguments as [default Rails helper](https://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_radio_buttons) except it don't accept a `block` as
@@ -1538,6 +1594,8 @@ This generates the following HTML:
1538
1594
  </div>
1539
1595
  ```
1540
1596
 
1597
+ _If form layout is inline, `collection_check_boxes` always render `inline` check boxes._
1598
+
1541
1599
  ## Date Helpers
1542
1600
 
1543
1601
  The multiple selects that the date and time helpers (`date_select`, `time_select`, `datetime_select`) generate are wrapped inside a `fieldset.rails-bootstrap-forms-[date|time|datetime]-select` tag.
@@ -1710,7 +1768,7 @@ This generates the following HTML:
1710
1768
  ## Submit Buttons
1711
1769
 
1712
1770
  `rails_bootstrap_form` allows to easily create submit button for the form. `rails_bootstrap_form` supports three color variants for submit buttons: `secondary`, `primary`, and `danger`. Submit buttons are supported in `vertical`, `horizontal`, and `inline` layout.
1713
- Submit buttons in inline form are wrapped inside `div.col-12` to properly render on small width devices.
1771
+ Submit buttons in inline form are wrapped inside `div.col-12` to properly align on small width devices.
1714
1772
 
1715
1773
  ![button_helpers](https://github.com/shivam091/rails_bootstrap_form/assets/7858927/f41a013b-b8c9-4689-a079-b8b102084cf0)
1716
1774
 
@@ -1743,7 +1801,7 @@ This generates the following HTML:
1743
1801
  <input type="submit" name="commit" value="Register" class="register-button btn btn-primary" data-disable-with="Register">
1744
1802
  ```
1745
1803
 
1746
- To render submit helper as a button helper, you can set `render_as_button` option to `true` or pass a block.
1804
+ To render submit helper as a button helper, you can set `render_as_button: true` option or pass a block.
1747
1805
 
1748
1806
  ![render_as_button](https://github.com/shivam091/rails_bootstrap_form/assets/7858927/dffd72d8-3acf-4029-be04-3bf7776e8d9c)
1749
1807
 
@@ -1786,6 +1844,8 @@ This generates the following HTML:
1786
1844
  </div>
1787
1845
  ```
1788
1846
 
1847
+ _`static_field` supports all the bootstrap options which are supported by `text_field`._
1848
+
1789
1849
  ## Floating Labels
1790
1850
 
1791
1851
  The `floating` option can be used to enable Bootstrap floating labels. This option is supported on text fields, text areas and dropdowns. Here's an example:
@@ -1850,7 +1910,7 @@ This generates the following HTML:
1850
1910
  </form>
1851
1911
  ```
1852
1912
 
1853
- _Floating labels gets disabled by `rails_bootstrap_form` automatically for unsupported helpers._
1913
+ _`rails_bootstrap_form` automatically disables floating labels for unsupported helpers._
1854
1914
 
1855
1915
  ## Validation and Errors
1856
1916
 
@@ -1913,6 +1973,9 @@ This generates the following HTML:
1913
1973
  </div>
1914
1974
  ```
1915
1975
 
1976
+ The `has-validation` CSS class is added to an input group when the field has errors.
1977
+ The `is-invalid` CSS class is added to floating label container when field with floating label has errors.
1978
+
1916
1979
  ## Required Fields
1917
1980
 
1918
1981
  A label that is associated with a mandatory field is automatically annotated with a `required` CSS class. `rails_bootstrap_form` provides styling for required fields.
@@ -6,5 +6,5 @@
6
6
 
7
7
  RailsBootstrapForm.configure do |config|
8
8
  # to make forms non-compliant with W3C.
9
- config.default_form_attributes = {role: "form", novalidate: true}
9
+ config.default_form_attributes = {novalidate: true}
10
10
  end
@@ -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 `form-control`.
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 = "form-control"
185
+ @field_class = nil
178
186
  @additional_field_class = nil
179
187
 
180
188
  @help_text = nil
@@ -72,11 +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(options[:class])
76
- field_classes << [
77
- bootstrap.field_class,
78
- bootstrap.additional_field_class
79
- ]
75
+ field_classes = Array(bootstrap.field_class) << [bootstrap.additional_field_class || css_options[:class]]
80
76
  field_classes << "is-invalid" if is_invalid?(attribute)
81
77
  if is_size_valid?(bootstrap)
82
78
  field_classes << "#{bootstrap.field_class}-#{bootstrap.size}"
@@ -10,21 +10,23 @@ module RailsBootstrapForm
10
10
  def self.included(base_class)
11
11
  [:check_box, :radio_button].each do |tag_name|
12
12
  define_method("#{tag_name}_label") do |attribute, value, options, bootstrap|
13
- label_options = {
14
- class: choice_label_classes(attribute, bootstrap, options)
15
- }
16
- label_options[:value] = value if tag_name.eql?(:radio_button)
17
- label_options[:for] = options[:id] if options[:id].present?
13
+ unless bootstrap.skip_label?
14
+ label_options = {
15
+ class: choice_label_classes(attribute, bootstrap, options)
16
+ }
17
+ label_options[:value] = value if tag_name.eql?(:radio_button)
18
+ label_options[:for] = options[:id] if options[:id].present?
18
19
 
19
- label_text = label_text(attribute, bootstrap)
20
+ label_text = label_text(attribute, bootstrap)
20
21
 
21
- label(attribute, label_text, label_options)
22
+ label(attribute, label_text, label_options)
23
+ end
22
24
  end
23
25
  end
24
26
 
25
27
  [:check_box, :radio_button].each do |tag_name|
26
28
  define_method("bootstrap_#{tag_name}") do |attribute, value, options, bootstrap|
27
- options[:class] = choice_classes(attribute, options)
29
+ options[:class] = choice_classes(attribute, bootstrap, options)
28
30
 
29
31
  if tag_name.eql?(:check_box)
30
32
  choice_field = check_box_without_bootstrap(attribute, options, value, nil)
@@ -38,8 +40,8 @@ module RailsBootstrapForm
38
40
  end
39
41
  end
40
42
 
41
- def choice_classes(attribute, options)
42
- classes = Array("form-check-input") << options[:class]
43
+ def choice_classes(attribute, bootstrap, options)
44
+ classes = Array("form-check-input") << [bootstrap.additional_field_class || options[:class]]
43
45
  classes << "is-invalid" if is_invalid?(attribute)
44
46
  classes.flatten.compact
45
47
  end
@@ -45,14 +45,13 @@ module RailsBootstrapForm
45
45
  options[:class] = the_class if the_class.present?
46
46
  end
47
47
 
48
- def remove_css_class!(options, css_class)
49
- the_class = options[:class].to_s.split(" ")
50
- options[:class] = (the_class - [css_class]).compact.join(" ")
51
- options.delete(:class) if options[:class].blank?
52
- end
48
+ # def remove_css_class!(options, css_class)
49
+ # the_class = options[:class].to_s.split(" ")
50
+ # options[:class] = (the_class - [css_class]).compact.join(" ")
51
+ # options.delete(:class) if options[:class].blank?
52
+ # end
53
53
 
54
- private :control_specific_class, :is_size_valid?, :add_css_class!,
55
- :remove_css_class!
54
+ private :control_specific_class, :is_size_valid?, :add_css_class!
56
55
  end
57
56
  end
58
57
  end
@@ -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?
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[:class] = ["trix-content", options[:class]].compact.join(" ")
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(*args)
12
- options = args.extract_options!
13
- attribute = args.first
14
-
15
- static_options = options.merge(
16
- readonly: true,
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
- }
21
- )
18
+ }.reverse_merge!(options.fetch(:bootstrap, {}))
19
+ end
22
20
 
23
- static_options[:value] = object.send(attribute) unless options.key?(:value)
21
+ options[:value] = object.send(attribute) unless options.key?(:value)
24
22
 
25
- text_field(attribute, static_options)
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
@@ -3,6 +3,6 @@
3
3
  # -*- warn_indent: true -*-
4
4
 
5
5
  module RailsBootstrapForm
6
- VERSION = "0.9.3".freeze
6
+ VERSION = "0.9.5".freeze
7
7
  REQUIRED_RAILS_VERSION = "~> 7.0".freeze
8
8
  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.3
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-04 00:00:00.000000000 Z
11
+ date: 2023-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: generator_spec