bootstrap_form 5.2.0 → 5.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d296af534429e0065b8f5aef6254dd12455e6317fd36f684b060b3c425c03e8
4
- data.tar.gz: aa02bc3031975302dbe4d556a1fcaa6751e2b4cbb961e737fa23b80516904ea2
3
+ metadata.gz: 4f254a69bb17aa95e9b912696e17d960c76a8b276946e3e33a0c4ade55cc3a38
4
+ data.tar.gz: 5d7d83dd48e78fc1dfbb9be6cea0cf12a4bdc9dbe646e3720152e4f78953adb3
5
5
  SHA512:
6
- metadata.gz: 0a402ef41606092aa37ec284382f754aea85d73dfc16b8b065ea130c6d47910d061afac644a0b0d38f1269f0c53caa2f987c8b5d4ce9dfa6105811919a40bc8f
7
- data.tar.gz: 546e5dbb15379578c5f06a4d6d40a362bd08d9dc4049cd4a7140cc7b29f459bfc8f914d8e114125d398be8b323102d4912653d589e008441eb288dda71fb0ebd
6
+ metadata.gz: 2e9d0227f8d07cd40fd0986cb67f0b86de8c759fd7e7b60d42e3ea8dd0d825555a62b5f60de26e30a8b08985cc9b38e42e765338d1ca628e50c5a8841ca64756
7
+ data.tar.gz: 74034f6ad801fea16c3002242b80647eed61732c9a15c8d6b4197f59cd232c7d361974ef42697fa4b81f03100d73e7699794a0a5454da03661bde1677045ee42
data/CHANGELOG.md CHANGED
@@ -6,11 +6,14 @@ https://github.com/bootstrap-ruby/bootstrap_form/releases
6
6
 
7
7
  ## Diffs
8
8
 
9
- - [Pending Release](https://github.com/bootstrap-ruby/bootstrap_form/compare/v5.2.0...HEAD)
9
+ - [5.2.2](https://github.com/bootstrap-ruby/bootstrap_form/compare/v5.2.1...v5.2.2)
10
+ [Closed issues](https://github.com/bootstrap-ruby/bootstrap_form/issues?q=closed%3A2023-05-23T10%3A00..2023-05-28T16%3A00)
11
+ - [5.2.1](https://github.com/bootstrap-ruby/bootstrap_form/compare/v5.2.0...v5.2.1)
12
+ [Closed issues](https://github.com/bootstrap-ruby/bootstrap_form/issues?q=closed%3A2023-05-20T23%3A59..2023-05-23T10%3A00)
10
13
  - [5.2.0](https://github.com/bootstrap-ruby/bootstrap_form/compare/v5.1.0...v5.2.0)
11
- [Issues](https://github.com/bootstrap-ruby/bootstrap_form/issues?q=closed%3A2022-06-25T17%3A22..2023-05-20T23%3A59)
14
+ [Closed issues](https://github.com/bootstrap-ruby/bootstrap_form/issues?q=closed%3A2022-06-25T17%3A22..2023-05-20T23%3A59)
12
15
  - [5.1.0](https://github.com/bootstrap-ruby/bootstrap_form/compare/v5.0.0...v5.1.0)
13
- [Issues](https://github.com/bootstrap-ruby/bootstrap_form/issues?q=closed%3A2021-11-12T05%3A58..2022-06-25T17%3A22)
16
+ [Closed issues](https://github.com/bootstrap-ruby/bootstrap_form/issues?q=closed%3A2021-11-12T05%3A58..2022-06-25T17%3A22)
14
17
  - [5.0.0](https://github.com/bootstrap-ruby/bootstrap_form/compare/v4.5.0...v5.0.0)
15
18
  - [4.5.0](https://github.com/bootstrap-ruby/bootstrap_form/compare/v4.4.0...v4.5.0)
16
19
  - [4.4.0](https://github.com/bootstrap-ruby/bootstrap_form/compare/v4.3.0...v4.4.0)
data/README.md CHANGED
@@ -125,8 +125,6 @@ This generates:
125
125
 
126
126
  ### bootstrap_form_with
127
127
 
128
- Note that `form_with` in Rails 5.1 does not add IDs to form elements and labels by default, which are both important to Bootstrap markup. This behaviour is corrected in Rails 5.2.
129
-
130
128
  To get started, just use the `bootstrap_form_with` helper in place of `form_with`. Here's an example:
131
129
 
132
130
  ![Example 2](demo/doc/screenshots/bootstrap/readme/02_example.png "Example 2")
@@ -200,7 +198,7 @@ date_field password_field time_field
200
198
  date_select phone_field time_select
201
199
  datetime_field radio_button time_zone_select
202
200
  datetime_local_field range_field url_field
203
- datetime_select rich_text_area (Rails 6+) week_field
201
+ datetime_select rich_text_area week_field
204
202
  ```
205
203
 
206
204
  By default, the helpers generate a `label` tag, and an `input`, `select`, or `textarea` tag, by calling the Rails `label` helper, and then the Rails helper with the same name as the `bootstrap_form` helper.
@@ -753,7 +751,7 @@ This generates:
753
751
  ```html
754
752
  <div class="mb-3">
755
753
  <label class="form-label" for="user_excellence">Excellence</label>
756
- <input class="form-control" id="user_excellence" name="user[excellence]" type="range">
754
+ <input class="form-range" id="user_excellence" name="user[excellence]" type="range">
757
755
  </div>
758
756
  ```
759
757
 
@@ -946,8 +944,6 @@ will be rendered as
946
944
 
947
945
  ## Rich Text Areas AKA Trix Editor
948
946
 
949
- If you're using Rails 6, `bootstrap_form` supports the `rich_text_area` helper.
950
-
951
947
  ![Example 34](demo/doc/screenshots/bootstrap/readme/34_example.png "Example 34")
952
948
  ```erb
953
949
  <%= f.rich_text_area(:life_story) %>
@@ -1369,18 +1365,29 @@ Rails normally wraps fields with validation errors in a `div.field_with_errors`,
1369
1365
  By default, fields that have validation errors will be outlined in red and the
1370
1366
  error will be displayed below the field. Here's an example:
1371
1367
 
1368
+ ![Example 44](demo/doc/screenshots/bootstrap/readme/44_example.png "Example 44")
1369
+ ```erb
1370
+ <%= bootstrap_form_for(@user_with_error) do |f| %>
1371
+ <%= f.email_field :email %>
1372
+ <% end %>
1373
+ ```
1374
+
1375
+ Generated HTML:
1376
+
1372
1377
  ```html
1373
- <div class="mb-3">
1374
- <label class="form-label form-control-label" for="user_email">Email</label>
1375
- <input class="form-control is-invalid" id="user_email" name="user[email]" type="email" value="">
1376
- <small class="invalid-feedback">can't be blank</small>
1377
- </div>
1378
+ <form accept-charset="UTF-8" action="/users" class="new_user" id="new_user" method="post">
1379
+ <div class="mb-3">
1380
+ <label class="form-label required" for="user_email">Email</label>
1381
+ <input aria-required="true" class="form-control is-invalid" id="user_email" name="user[email]" required="required" type="email" value="steve.example.com">
1382
+ <div class="invalid-feedback">is invalid</div>
1383
+ </div>
1384
+ </form>
1378
1385
  ```
1379
1386
 
1380
1387
  You can turn off inline errors for the entire form like this:
1381
1388
 
1382
1389
  ```erb
1383
- <%= bootstrap_form_for(@user, inline_errors: false) do |f| %>
1390
+ <%= bootstrap_form_for(@user_with_error, inline_errors: false) do |f| %>
1384
1391
  ...
1385
1392
  <% end %>
1386
1393
  ```
@@ -1390,12 +1397,24 @@ You can turn off inline errors for the entire form like this:
1390
1397
  You can also display validation errors in the field's label; just turn
1391
1398
  on the `:label_errors` option. Here's an example:
1392
1399
 
1400
+ ![Example 45](demo/doc/screenshots/bootstrap/readme/45_example.png "Example 45")
1393
1401
  ```erb
1394
- <%= bootstrap_form_for(@user, label_errors: true) do |f| %>
1395
- ...
1402
+ <%= bootstrap_form_for(@user_with_error, label_errors: true) do |f| %>
1403
+ <%= f.email_field :email %>
1396
1404
  <% end %>
1397
1405
  ```
1398
1406
 
1407
+ Generated HTML:
1408
+
1409
+ ```html
1410
+ <form accept-charset="UTF-8" action="/users" class="new_user" id="new_user" method="post">
1411
+ <div class="mb-3">
1412
+ <label class="form-label required text-danger" for="user_email">Email is invalid</label>
1413
+ <input aria-required="true" class="form-control is-invalid" id="user_email" name="user[email]" required="required" type="email" value="steve.example.com">
1414
+ </div>
1415
+ </form>
1416
+ ```
1417
+
1399
1418
  By default, turning on `:label_errors` will also turn off
1400
1419
  `:inline_errors`. If you want both turned on, you can do that too:
1401
1420
 
@@ -1411,7 +1430,7 @@ To display an error message with an error summary, you can use the
1411
1430
  `alert_message` helper. This won't output anything unless a model validation
1412
1431
  has failed.
1413
1432
 
1414
- ![Example 44](demo/doc/screenshots/bootstrap/readme/44_example.png "Example 44")
1433
+ ![Example 46](demo/doc/screenshots/bootstrap/readme/46_example.png "Example 46")
1415
1434
  ```erb
1416
1435
  <%= bootstrap_form_for @user_with_error do |f| %>
1417
1436
  <%= f.alert_message "Please fix the errors below." %>
@@ -1434,7 +1453,7 @@ Which outputs:
1434
1453
 
1435
1454
  You can turn off the error summary like this:
1436
1455
 
1437
- ![Example 45](demo/doc/screenshots/bootstrap/readme/45_example.png "Example 45")
1456
+ ![Example 47](demo/doc/screenshots/bootstrap/readme/47_example.png "Example 47")
1438
1457
  ```erb
1439
1458
  <%= bootstrap_form_for @user_with_error do |f| %>
1440
1459
  <%= f.alert_message "Please fix the errors below.", error_summary: false %>
@@ -1451,7 +1470,7 @@ This generates:
1451
1470
 
1452
1471
  To output a simple unordered list of errors, use the `error_summary` helper.
1453
1472
 
1454
- ![Example 46](demo/doc/screenshots/bootstrap/readme/46_example.png "Example 46")
1473
+ ![Example 48](demo/doc/screenshots/bootstrap/readme/48_example.png "Example 48")
1455
1474
  ```erb
1456
1475
  <%= bootstrap_form_for @user_with_error do |f| %>
1457
1476
  <%= f.error_summary %>
@@ -1473,7 +1492,7 @@ Which outputs:
1473
1492
 
1474
1493
  If you want to display a custom inline error for a specific attribute not represented by a form field, use the `errors_on` helper.
1475
1494
 
1476
- ![Example 47](demo/doc/screenshots/bootstrap/readme/47_example.png "Example 47")
1495
+ ![Example 49](demo/doc/screenshots/bootstrap/readme/49_example.png "Example 49")
1477
1496
  ```erb
1478
1497
  <%= bootstrap_form_for @user_with_error do |f| %>
1479
1498
  <%= f.errors_on :email %>
@@ -1490,7 +1509,7 @@ Which outputs:
1490
1509
 
1491
1510
  You can hide the attribute name like this:
1492
1511
 
1493
- ![Example 48](demo/doc/screenshots/bootstrap/readme/48_example.png "Example 48")
1512
+ ![Example 50](demo/doc/screenshots/bootstrap/readme/50_example.png "Example 50")
1494
1513
  ```erb
1495
1514
  <%= bootstrap_form_for @user_with_error do |f| %>
1496
1515
  <%= f.errors_on :email, hide_attribute_name: true %>
@@ -1507,7 +1526,7 @@ Which outputs:
1507
1526
 
1508
1527
  You can also use a custom class for the wrapping div, like this:
1509
1528
 
1510
- ![Example 49](demo/doc/screenshots/bootstrap/readme/49_example.png "Example 49")
1529
+ ![Example 51](demo/doc/screenshots/bootstrap/readme/51_example.png "Example 51")
1511
1530
  ```erb
1512
1531
  <%= bootstrap_form_for @user_with_error do |f| %>
1513
1532
  <%= f.errors_on :email, custom_class: 'custom-error' %>
@@ -1542,7 +1561,7 @@ ActiveModel::Validations::PresenceValidator.
1542
1561
 
1543
1562
  In cases where this behaviour is undesirable, use the `required` option to force the class to be present or absent:
1544
1563
 
1545
- ![Example 50](demo/doc/screenshots/bootstrap/readme/50_example.png "Example 50")
1564
+ ![Example 52](demo/doc/screenshots/bootstrap/readme/52_example.png "Example 52")
1546
1565
  ```erb
1547
1566
  <%= f.password_field :login, label: "New Username", required: true %>
1548
1567
  <%= f.password_field :password, label: "New Password", required: false %>
@@ -1565,7 +1584,7 @@ This generates:
1565
1584
 
1566
1585
  Adding a form control for a `belongs_to` field will automatically pick up the associated presence validator.
1567
1586
 
1568
- ![Example 51](demo/doc/screenshots/bootstrap/readme/51_example.png "Example 51")
1587
+ ![Example 53](demo/doc/screenshots/bootstrap/readme/53_example.png "Example 53")
1569
1588
  ```erb
1570
1589
  <%= bootstrap_form_for(@address, url: '/address') do |f| %>
1571
1590
  <%= f.collection_select :user_id, @users, :id, :email, include_blank: "Select a value" %>
data/RELEASING.md CHANGED
@@ -10,22 +10,37 @@ Follow these steps to release a new version of bootstrap_form to rubygems.org.
10
10
 
11
11
  ## How to release
12
12
 
13
- 1. Run `BUNDLE_GEMFILE=gemfiles/7.0.gemfile bundle update` to make sure that you have all the gems necessary for testing and releasing.
13
+ 1. Make sure that you have all the gems necessary for testing and releasing.
14
+
15
+ BUNDLE_GEMFILE=gemfiles/7.0.gemfile bundle update
16
+
14
17
  2. **Ensure the tests are passing by running the tests**
15
18
 
16
19
  (There should be no errors or warnings.)
17
20
 
18
21
  BUNDLE_GEMFILE=gemfiles/7.0.gemfile bundle exec rake test
19
22
 
20
- 2. **Ensure the demo tests are passing by running**
23
+ 3. **Ensure the demo tests are passing by running**
21
24
 
22
25
  cd demo
23
26
  bundle update
24
27
  bundle exec rake test:all
25
-
26
- 3. Determine which would be the correct next version number according to [semver](http://semver.org/).
27
- 4. Update the version in `./lib/bootstrap_form/version.rb`.
28
- 5. Update the GitHub diff links at the beginning of `CHANGELOG.md` (The pattern should be obvious when you look at them).
29
- 6. Update the installation instructions in `README.md` to use the new version.
30
- 7. Commit the CHANGELOG and version changes in a single commit; the message should be "Preparing vX.Y.Z" where `X.Y.Z` is the version being released.
31
- 8. Run `bundle exec rake release`; this will tag, push to GitHub, and publish to rubygems.org.
28
+ cd -
29
+
30
+ 4. Determine which would be the correct next version number according to [semver](http://semver.org/).
31
+ 5. Update the version in `./lib/bootstrap_form/version.rb`.
32
+ 6. Update the GitHub diff links at the beginning of `CHANGELOG.md` (The pattern should be obvious when you look at them).
33
+ 7. Update the installation instructions in `README.md` to use the new version.
34
+ 8. Commit the CHANGELOG and version changes in a single commit; the message should be "Preparing vX.Y.Z" where `X.Y.Z` is the version being released.
35
+ 9. Tag, push to GitHub, and publish to rubygems.org:
36
+
37
+ bundle exec rake release
38
+
39
+ 10. Go to https://github.com/bootstrap-ruby/bootstrap_form/releases and create the new release and add release notes by clicking the "Generate release notes" button.
40
+ Add the link of closed issues from CHANGELOG.
41
+ Group the commits in sections:
42
+ * ### New features
43
+ * ### Bugfixes
44
+ * ### Performance
45
+ * ### Documentation
46
+ * ### Development
data/Rakefile CHANGED
@@ -1,12 +1,14 @@
1
1
  begin
2
2
  require 'bundler/setup'
3
+
4
+ require 'bundler/gem_tasks'
5
+ require "minitest/test_task"
6
+ require 'rdoc/task'
3
7
  require 'rubocop/rake_task'
4
8
  rescue LoadError
5
9
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
10
  end
7
11
 
8
- require 'rdoc/task'
9
-
10
12
  RDoc::Task.new(:rdoc) do |rdoc|
11
13
  rdoc.rdoc_dir = 'rdoc'
12
14
  rdoc.title = 'BootstrapForm'
@@ -15,10 +17,6 @@ RDoc::Task.new(:rdoc) do |rdoc|
15
17
  rdoc.rdoc_files.include('lib/**/*.rb')
16
18
  end
17
19
 
18
- require 'bundler/gem_tasks'
19
-
20
- require "minitest/test_task"
21
-
22
20
  Minitest::TestTask.create(:test) do |t|
23
21
  t.libs << "test"
24
22
  t.libs << "lib"
@@ -26,12 +24,6 @@ Minitest::TestTask.create(:test) do |t|
26
24
  t.test_globs = ["test/**/*_test.rb"]
27
25
  end
28
26
 
29
- # This automatically updates GitHub Releases whenever we `rake release` the gem
30
- task "release:rubygem_push" do
31
- require "chandler/tasks"
32
- Rake.application.invoke_task("chandler:push")
33
- end
34
-
35
27
  desc 'Run RuboCop checks'
36
28
  RuboCop::RakeTask.new(:rubocop)
37
29
 
@@ -12,7 +12,7 @@ module BootstrapForm
12
12
  end
13
13
 
14
14
  def association_error?(name)
15
- object.class.reflections.any? do |association_name, a|
15
+ object.class.try(:reflections)&.any? do |association_name, a|
16
16
  next unless a.is_a?(ActiveRecord::Reflection::BelongsToReflection)
17
17
  next unless a.foreign_key == name.to_s
18
18
 
@@ -26,21 +26,23 @@ module BootstrapForm
26
26
  target = obj.instance_of?(Class) ? obj : obj.class
27
27
  return false unless target.respond_to? :validators_on
28
28
 
29
- presence_validator?(target_validators(target, attribute)) ||
29
+ presence_validator?(target_unconditional_validators(target, attribute)) ||
30
30
  required_association?(target, attribute)
31
31
  end
32
32
 
33
33
  def required_association?(target, attribute)
34
- target.reflections.find do |name, a|
34
+ target.try(:reflections)&.find do |name, a|
35
35
  next unless a.is_a?(ActiveRecord::Reflection::BelongsToReflection)
36
36
  next unless a.foreign_key == attribute.to_s
37
37
 
38
- presence_validator?(target_validators(target, name))
38
+ presence_validator?(target_unconditional_validators(target, name))
39
39
  end
40
40
  end
41
41
 
42
- def target_validators(target, attribute)
43
- target.validators_on(attribute).map(&:class)
42
+ def target_unconditional_validators(target, attribute)
43
+ target.validators_on(attribute)
44
+ .reject { |validator| validator.options[:if].present? || validator.options[:unless].present? }
45
+ .map(&:class)
44
46
  end
45
47
 
46
48
  def presence_validator?(target_validators)
@@ -65,7 +67,7 @@ module BootstrapForm
65
67
 
66
68
  def get_error_messages(name)
67
69
  messages = object.errors[name]
68
- object.class.reflections.each do |association_name, a|
70
+ object.class.try(:reflections)&.each do |association_name, a|
69
71
  next unless a.is_a?(ActiveRecord::Reflection::BelongsToReflection)
70
72
  next unless a.foreign_key == name.to_s
71
73
 
@@ -33,7 +33,7 @@ module BootstrapForm
33
33
  include BootstrapForm::Inputs::PhoneField
34
34
  include BootstrapForm::Inputs::RadioButton
35
35
  include BootstrapForm::Inputs::RangeField
36
- include BootstrapForm::Inputs::RichTextArea if Rails::VERSION::MAJOR >= 6
36
+ include BootstrapForm::Inputs::RichTextArea
37
37
  include BootstrapForm::Inputs::SearchField
38
38
  include BootstrapForm::Inputs::Select
39
39
  include BootstrapForm::Inputs::TelephoneField
@@ -6,8 +6,8 @@ module BootstrapForm
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  class_methods do
9
- def bootstrap_field(field_name)
10
- define_method "#{field_name}_with_bootstrap" do |name, options={}|
9
+ def bootstrap_field(field_name, control_class: nil)
10
+ define_method "#{field_name}_with_bootstrap" do |name, options={ control_class: control_class }.compact|
11
11
  form_group_builder(name, options) do
12
12
  prepend_and_append_input(name, options) do
13
13
  options[:placeholder] ||= name if options[:floating]
@@ -7,7 +7,7 @@ module BootstrapForm
7
7
  include Base
8
8
 
9
9
  included do
10
- bootstrap_field :range_field
10
+ bootstrap_field :range_field, control_class: "form-range"
11
11
  end
12
12
  end
13
13
  end
@@ -25,7 +25,7 @@ module BootstrapForm
25
25
  autoload :PhoneField
26
26
  autoload :RadioButton
27
27
  autoload :RangeField
28
- autoload :RichTextArea if Rails::VERSION::MAJOR >= 6
28
+ autoload :RichTextArea
29
29
  autoload :SearchField
30
30
  autoload :Select
31
31
  autoload :TelephoneField
@@ -1,4 +1,4 @@
1
1
  module BootstrapForm
2
- VERSION = "5.2.0".freeze
2
+ VERSION = "5.2.2".freeze
3
3
  REQUIRED_RAILS_VERSION = ">= 6.0".freeze
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0
4
+ version: 5.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Potenza
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-05-20 00:00:00.000000000 Z
12
+ date: 2023-05-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack