simple_form 5.1.0 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +64 -16
  5. data/lib/generators/simple_form/install_generator.rb +2 -2
  6. data/lib/generators/simple_form/templates/README +1 -1
  7. data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +1 -1
  8. data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +126 -194
  9. data/lib/simple_form/components/label_input.rb +1 -1
  10. data/lib/simple_form/form_builder.rb +2 -6
  11. data/lib/simple_form/inputs/boolean_input.rb +6 -2
  12. data/lib/simple_form/inputs/grouped_collection_select_input.rb +1 -1
  13. data/lib/simple_form/inputs/priority_input.rb +16 -2
  14. data/lib/simple_form/railtie.rb +4 -0
  15. data/lib/simple_form/version.rb +1 -1
  16. data/lib/simple_form/wrappers/leaf.rb +1 -1
  17. data/lib/simple_form.rb +9 -5
  18. metadata +11 -83
  19. data/test/action_view_extensions/builder_test.rb +0 -634
  20. data/test/action_view_extensions/form_helper_test.rb +0 -172
  21. data/test/components/custom_components_test.rb +0 -62
  22. data/test/components/label_test.rb +0 -352
  23. data/test/form_builder/association_test.rb +0 -252
  24. data/test/form_builder/button_test.rb +0 -48
  25. data/test/form_builder/error_notification_test.rb +0 -80
  26. data/test/form_builder/error_test.rb +0 -281
  27. data/test/form_builder/general_test.rb +0 -539
  28. data/test/form_builder/hint_test.rb +0 -150
  29. data/test/form_builder/input_field_test.rb +0 -195
  30. data/test/form_builder/label_test.rb +0 -136
  31. data/test/form_builder/wrapper_test.rb +0 -378
  32. data/test/generators/simple_form_generator_test.rb +0 -43
  33. data/test/inputs/boolean_input_test.rb +0 -243
  34. data/test/inputs/collection_check_boxes_input_test.rb +0 -323
  35. data/test/inputs/collection_radio_buttons_input_test.rb +0 -446
  36. data/test/inputs/collection_select_input_test.rb +0 -380
  37. data/test/inputs/color_input_test.rb +0 -10
  38. data/test/inputs/datetime_input_test.rb +0 -176
  39. data/test/inputs/disabled_test.rb +0 -92
  40. data/test/inputs/discovery_test.rb +0 -142
  41. data/test/inputs/file_input_test.rb +0 -17
  42. data/test/inputs/general_test.rb +0 -133
  43. data/test/inputs/grouped_collection_select_input_test.rb +0 -183
  44. data/test/inputs/hidden_input_test.rb +0 -32
  45. data/test/inputs/numeric_input_test.rb +0 -177
  46. data/test/inputs/priority_input_test.rb +0 -50
  47. data/test/inputs/readonly_test.rb +0 -102
  48. data/test/inputs/required_test.rb +0 -158
  49. data/test/inputs/rich_text_area_input_test.rb +0 -15
  50. data/test/inputs/string_input_test.rb +0 -158
  51. data/test/inputs/text_input_test.rb +0 -37
  52. data/test/simple_form_test.rb +0 -18
  53. data/test/support/discovery_inputs.rb +0 -65
  54. data/test/support/misc_helpers.rb +0 -274
  55. data/test/support/mock_controller.rb +0 -30
  56. data/test/support/models.rb +0 -357
  57. data/test/test_helper.rb +0 -95
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8260fa0dbaf1a82ae7b8a5c120c4f26ba4e2f0c03a9821241bf6d2d193962384
4
- data.tar.gz: f1ef61699c7246302e31eb405c734816491b1698419bc810643b71c54d7ffb2d
3
+ metadata.gz: 3b89606503cd2fc01363418e51dd00630a770820b8482f35aa85ddba1a653cc5
4
+ data.tar.gz: 1a078f896c0e4bd41b0462a5b591fcc04038dbb0dd64c65c61b5584450a9b569
5
5
  SHA512:
6
- metadata.gz: 31be8f22b6fbe417be6051466e6370c8d54e4667df16c1506a84580df69376daae06af454bb46e21b8b86e61fed6efaf954f45c876005f2b33dde00ad3ca8374
7
- data.tar.gz: 756ef0c153e13b61a6d6823f3ea9f615ee507e329effce3c31ca477b85de86c6b0aa7bb645802be3c405281b621777191b1c34efba2cdeceb9035c2dfbb9ce82
6
+ metadata.gz: 17a0ecd1d326536cdb1e4e1291bcfbad43fac2d8e4e0895ad0619515e9f951c4618da9b4ad8c568bcd9b702f94227f58b3967a14eb9b7adc3343ca07cfb8f451
7
+ data.tar.gz: 810793e24f74792775bbe3e5bba0b157f59673879b8c6c360c4af15ba2d91fc0d293eace5556aba5b32e7a99f01d7e3e96099046401e802fbba3a1b2bcddcaf5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## 5.3.0
2
+
3
+ * Add support for Rails 7.1. (no meaningful changes required.)
4
+ * Add `SimpleForm.deprecator` to integrate with new application deprecators in Rails 7.1.
5
+ * Remove test files from the gem package. [@orien](https://github.com/orien)
6
+ * Speed up input mapping lookup by avoiding rescuing exceptions. [@meanphil](https://github.com/meanphil) [@kriom](https://github.com/kriom) [@egeek](https://github.com/egeek)
7
+
8
+ ## 5.2.0
9
+
10
+ * Add support for Rails 7.0 and Ruby 3.1/3.2 (no changes required)
11
+ * Fix escaping issue on boolean input with `include_hidden: false` and custom wrapper.
12
+ * Update Bootstrap install generator version 5. [@mhw](https://github.com/mhw)
13
+ * Accept proc as `group_method` for grouped collection select
14
+ * Honor `include_hidden` option on inline boolean inputs [@yboulkaid](https://github.com/yboulkaid)
15
+ * Fix deprecation error when using country_select input.
16
+
1
17
  ## 5.1.0
2
18
 
3
19
  * Remove `I18nCache` module entirely. It was added complexity for very little gain in some translations, and caused extra trouble upgrading to Ruby 3. If you need that level of caching consider looking into I18n caching as a whole.
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2020 Rafael França, Carlos Antônio da Silva
1
+ Copyright (c) 2020-2023 Rafael França, Carlos Antônio da Silva
2
2
  Copyright (c) 2009-2019 Plataformatec
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ![Simple Form Logo](https://raw.github.com/heartcombo/simple_form/master/simple_form.png)
1
+ ![Simple Form Logo](https://raw.github.com/heartcombo/simple_form/main/simple_form.png)
2
2
 
3
3
  Rails forms made easy.
4
4
 
@@ -9,6 +9,43 @@ which we are thankful for and should make you feel right at home.
9
9
 
10
10
  INFO: This README refers to **Simple Form** 5.0. For older releases, check the related branch for your version.
11
11
 
12
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
13
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
14
+ ## Table of Contents
15
+
16
+ - [Installation](#installation)
17
+ - [Bootstrap](#bootstrap-5)
18
+ - [Zurb Foundation 5](#zurb-foundation-5)
19
+ - [Country Select](#country-select)
20
+ - [Usage](#usage)
21
+ - [Stripping away all wrapper divs](#stripping-away-all-wrapper-divs)
22
+ - [Collections](#collections)
23
+ - [Priority](#priority)
24
+ - [Associations](#associations)
25
+ - [Buttons](#buttons)
26
+ - [Wrapping Rails Form Helpers](#wrapping-rails-form-helpers)
27
+ - [Extra helpers](#extra-helpers)
28
+ - [Simple Fields For](#simple-fields-for)
29
+ - [Collection Radio Buttons](#collection-radio-buttons)
30
+ - [Collection Check Boxes](#collection-check-boxes)
31
+ - [Available input types and defaults for each column type](#available-input-types-and-defaults-for-each-column-type)
32
+ - [Custom inputs](#custom-inputs)
33
+ - [Custom form builder](#custom-form-builder)
34
+ - [I18n](#i18n)
35
+ - [Configuration](#configuration)
36
+ - [The wrappers API](#the-wrappers-api)
37
+ - [Custom Components](#custom-components)
38
+ - [HTML 5 Notice](#html-5-notice)
39
+ - [Using non Active Record objects](#using-non-active-record-objects)
40
+ - [Information](#information)
41
+ - [RDocs](#rdocs)
42
+ - [Supported Ruby / Rails versions](#supported-ruby--rails-versions)
43
+ - [Bug reports](#bug-reports)
44
+ - [Maintainers](#maintainers)
45
+ - [License](#license)
46
+
47
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
48
+
12
49
  ## Installation
13
50
 
14
51
  Add it to your Gemfile:
@@ -29,21 +66,23 @@ Run the generator:
29
66
  rails generate simple_form:install
30
67
  ```
31
68
 
32
- ### Bootstrap
69
+ ### Bootstrap 5
33
70
 
34
- **Simple Form** can be easily integrated to the [Bootstrap](http://getbootstrap.com/).
35
- To do that you have to use the `bootstrap` option in the install generator, like this:
71
+ **Simple Form** can be easily integrated with [Bootstrap 5](http://getbootstrap.com/).
72
+ Use the `bootstrap` option in the install generator, like this:
36
73
 
37
74
  ```console
38
75
  rails generate simple_form:install --bootstrap
39
76
  ```
40
77
 
78
+ This will add an initializer that configures **Simple Form** wrappers for
79
+ Bootstrap 5's [form controls](https://getbootstrap.com/docs/5.0/forms/overview/).
41
80
  You have to be sure that you added a copy of the [Bootstrap](http://getbootstrap.com/)
42
81
  assets on your application.
43
82
 
44
83
  For more information see the generator output, our
45
- [example application code](https://github.com/rafaelfranca/simple_form-bootstrap) and
46
- [the live example app](http://simple-form-bootstrap.plataformatec.com.br/).
84
+ [example application code](https://github.com/heartcombo/simple_form-bootstrap) and
85
+ [the live example app](https://simple-form-bootstrap.herokuapp.com/).
47
86
 
48
87
  ### Zurb Foundation 5
49
88
 
@@ -116,7 +155,7 @@ of any of them:
116
155
  ```erb
117
156
  <%= simple_form_for @user do |f| %>
118
157
  <%= f.input :username, label_html: { class: 'my_class' }, hint_html: { class: 'hint_class' } %>
119
- <%= f.input :password, hint: false, error_html: { id: 'password_error'} %>
158
+ <%= f.input :password, hint: false, error_html: { id: 'password_error' } %>
120
159
  <%= f.input :password_confirmation, label: false %>
121
160
  <%= f.button :submit %>
122
161
  <% end %>
@@ -218,7 +257,18 @@ the wrapper as well:
218
257
  <%= f.input :date_of_birth, as: :date, start_year: Date.today.year - 90,
219
258
  end_year: Date.today.year - 12, discard_day: true,
220
259
  order: [:month, :year] %>
221
- <%= f.input :accepts, as: :boolean, checked_value: true, unchecked_value: false %>
260
+ <%= f.input :accepts, as: :boolean, checked_value: 'positive', unchecked_value: 'negative' %>
261
+ <%= f.button :submit %>
262
+ <% end %>
263
+ ```
264
+
265
+ By default, **Simple Form** generates a hidden field to handle the un-checked case for boolean fields.
266
+ Passing `unchecked_value: false` in the options for boolean fields will cause this hidden field to be omitted,
267
+ following the convention in Rails. You can also specify `include_hidden: false` to skip the hidden field:
268
+
269
+ ```erb
270
+ <%= simple_form_for @user do |f| %>
271
+ <%= f.input :just_the_checked_case, as: :boolean, include_hidden: false %>
222
272
  <%= f.button :submit %>
223
273
  <% end %>
224
274
  ```
@@ -285,7 +335,7 @@ end
285
335
  </form>
286
336
  ```
287
337
 
288
- To view the actual RDocs for this, check them out here - http://rubydoc.info/github/heartcombo/simple_form/master/SimpleForm/FormBuilder:input_field
338
+ To view the actual RDocs for this, check them out here - http://rubydoc.info/github/heartcombo/simple_form/main/SimpleForm/FormBuilder:input_field
289
339
 
290
340
  ### Collections
291
341
 
@@ -326,14 +376,13 @@ If you want to change this behavior you must make it explicit, like this:
326
376
  <% end %>
327
377
  ```
328
378
 
329
- All other options given are sent straight to the underlying helper. For example, you can give prompt as:
379
+ All other options given are sent straight to the underlying Rails helper(s): [`collection_select`](http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_select), [`collection_check_boxes`](http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_check_boxes), [`collection_radio_buttons`](http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_radio_buttons). For example, you can pass `prompt` and `selected` as:
330
380
 
331
381
  ```ruby
332
382
  f.input :age, collection: 18..60, prompt: "Select your age", selected: 21
333
383
  ```
334
- Extra options are passed into helper [`collection_select`](http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_select).
335
384
 
336
- You may also find it useful to explicitly pass a value to the optional `:selected`, especially if passing a collection of nested objects.
385
+ It may also be useful to explicitly pass a value to the optional `:selected` like above, especially if passing a collection of nested objects.
337
386
 
338
387
  It is also possible to create grouped collection selects, that will use the html *optgroup* tags, like this:
339
388
 
@@ -1062,7 +1111,7 @@ Finally, add a new wrapper to the config/initializers/simple_form.rb file:
1062
1111
  ```ruby
1063
1112
  config.wrappers :with_numbers, tag: 'div', class: 'row', error_class: 'error' do |b|
1064
1113
  b.use :html5
1065
- b.use :number, wrap_with: { tag: 'div', class: 'span1 number'}
1114
+ b.use :number, wrap_with: { tag: 'div', class: 'span1 number' }
1066
1115
  b.wrapper tag: 'div', class: 'span8' do |ba|
1067
1116
  ba.use :placeholder
1068
1117
  ba.use :label
@@ -1214,7 +1263,7 @@ end
1214
1263
 
1215
1264
  You can view the **Simple Form** documentation in RDoc format here:
1216
1265
 
1217
- http://rubydoc.info/github/heartcombo/simple_form/master/frames
1266
+ http://rubydoc.info/github/heartcombo/simple_form/main/frames
1218
1267
 
1219
1268
  ### Supported Ruby / Rails versions
1220
1269
 
@@ -1240,11 +1289,10 @@ If you have discovered a security related bug, please do NOT use the GitHub issu
1240
1289
  * Felipe Renan (https://github.com/feliperenan)
1241
1290
 
1242
1291
  [![Gem Version](https://fury-badge.herokuapp.com/rb/simple_form.png)](http://badge.fury.io/rb/simple_form)
1243
- [![Code Climate](https://codeclimate.com/github/heartcombo/simple_form.png)](https://codeclimate.com/github/heartcombo/simple_form)
1244
1292
  [![Inline docs](http://inch-ci.org/github/heartcombo/simple_form.png)](http://inch-ci.org/github/heartcombo/simple_form)
1245
1293
 
1246
1294
  ## License
1247
1295
 
1248
- MIT License. Copyright 2020 Rafael França, Carlos Antônio da Silva. Copyright 2009-2019 Plataformatec.
1296
+ MIT License. Copyright 2020-2023 Rafael França, Carlos Antônio da Silva. Copyright 2009-2019 Plataformatec.
1249
1297
 
1250
1298
  The Simple Form logo is licensed under [Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License](https://creativecommons.org/licenses/by-nc-nd/4.0/).
@@ -5,12 +5,12 @@ module SimpleForm
5
5
  desc "Copy SimpleForm default files"
6
6
  source_root File.expand_path('../templates', __FILE__)
7
7
  class_option :template_engine, desc: 'Template engine to be invoked (erb, haml or slim).'
8
- class_option :bootstrap, type: :boolean, desc: 'Add the Bootstrap wrappers to the SimpleForm initializer.'
8
+ class_option :bootstrap, type: :boolean, desc: 'Add the Bootstrap 5 wrappers to the SimpleForm initializer.'
9
9
  class_option :foundation, type: :boolean, desc: 'Add the Zurb Foundation 5 wrappers to the SimpleForm initializer.'
10
10
 
11
11
  def info_bootstrap
12
12
  return if options.bootstrap? || options.foundation?
13
- puts "SimpleForm 3 supports Bootstrap and Zurb Foundation 5. If you want "\
13
+ puts "SimpleForm supports Bootstrap 5 and Zurb Foundation 5. If you want "\
14
14
  "a configuration that is compatible with one of these frameworks, then please " \
15
15
  "re-run this generator with --bootstrap or --foundation as an option."
16
16
  end
@@ -5,6 +5,6 @@
5
5
 
6
6
  For usage examples and documentation, see:
7
7
 
8
- http://simple-form-bootstrap.plataformatec.com.br/
8
+ https://simple-form-bootstrap.herokuapp.com
9
9
 
10
10
  ===============================================================================
@@ -112,7 +112,7 @@ SimpleForm.setup do |config|
112
112
  # You can define the class to use on all labels. Default is nil.
113
113
  # config.label_class = nil
114
114
 
115
- # You can define the default class to be used on forms. Can be overriden
115
+ # You can define the default class to be used on forms. Can be overridden
116
116
  # with `html: { :class }`. Defaulting to none.
117
117
  # config.default_form_class = nil
118
118