simple_form 4.1.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +57 -9
  3. data/MIT-LICENSE +2 -1
  4. data/README.md +47 -51
  5. data/lib/generators/simple_form/templates/README +2 -3
  6. data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +1 -4
  7. data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +26 -25
  8. data/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +1 -1
  9. data/lib/simple_form.rb +22 -5
  10. data/lib/simple_form/components/labels.rb +3 -5
  11. data/lib/simple_form/components/maxlength.rb +0 -4
  12. data/lib/simple_form/components/minlength.rb +0 -4
  13. data/lib/simple_form/form_builder.rb +23 -3
  14. data/lib/simple_form/inputs.rb +1 -0
  15. data/lib/simple_form/inputs/base.rb +0 -3
  16. data/lib/simple_form/inputs/collection_check_boxes_input.rb +1 -1
  17. data/lib/simple_form/inputs/collection_input.rb +3 -5
  18. data/lib/simple_form/inputs/priority_input.rb +0 -4
  19. data/lib/simple_form/inputs/rich_text_area_input.rb +12 -0
  20. data/lib/simple_form/tags.rb +6 -2
  21. data/lib/simple_form/version.rb +1 -1
  22. data/lib/simple_form/wrappers/root.rb +8 -3
  23. data/test/action_view_extensions/builder_test.rb +22 -4
  24. data/test/components/label_test.rb +0 -4
  25. data/test/form_builder/association_test.rb +6 -0
  26. data/test/form_builder/general_test.rb +17 -19
  27. data/test/form_builder/label_test.rb +1 -1
  28. data/test/form_builder/wrapper_test.rb +8 -1
  29. data/test/inputs/collection_check_boxes_input_test.rb +8 -4
  30. data/test/inputs/collection_radio_buttons_input_test.rb +8 -4
  31. data/test/inputs/collection_select_input_test.rb +6 -4
  32. data/test/inputs/priority_input_test.rb +4 -4
  33. data/test/inputs/rich_text_area_input_test.rb +15 -0
  34. data/test/support/misc_helpers.rb +2 -2
  35. data/test/support/models.rb +28 -2
  36. data/test/test_helper.rb +7 -4
  37. metadata +16 -15
  38. data/lib/simple_form/i18n_cache.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1461390ccbd2b434d67a43a84ada68f255d08bc48a9e23d7734075c8f105b400
4
- data.tar.gz: c81c4b918e6f9e467081e8b534273ef8807ef6e508da40077fe4c91b5b85a66f
3
+ metadata.gz: 8260fa0dbaf1a82ae7b8a5c120c4f26ba4e2f0c03a9821241bf6d2d193962384
4
+ data.tar.gz: f1ef61699c7246302e31eb405c734816491b1698419bc810643b71c54d7ffb2d
5
5
  SHA512:
6
- metadata.gz: 71d69573ae8125232a436ea4c23115584497647de1a3b5fa996c9c95f78599b3a3e9ff07ce0812cd5370a1e2c0351dc8fdc43bbea30b7f35d6c68213c68a5f84
7
- data.tar.gz: dacdc01de808196a155ad1219f913bafff072578ad0bb3c0a9602a9f0377d4359f03e54880dd77a3e27307a35754568064d9dd5dcec95abf8a93f5f0164149a8
6
+ metadata.gz: 31be8f22b6fbe417be6051466e6370c8d54e4667df16c1506a84580df69376daae06af454bb46e21b8b86e61fed6efaf954f45c876005f2b33dde00ad3ca8374
7
+ data.tar.gz: 756ef0c153e13b61a6d6823f3ea9f615ee507e329effce3c31ca477b85de86c6b0aa7bb645802be3c405281b621777191b1c34efba2cdeceb9035c2dfbb9ce82
data/CHANGELOG.md CHANGED
@@ -1,10 +1,58 @@
1
- ## Unreleased
1
+ ## 5.1.0
2
+
3
+ * 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.
4
+ * Add support for Ruby 3.0, drop support for Ruby < 2.5.
5
+ * Add support for Rails 6.1, drop support for Rails < 5.2.
6
+ * Move CI to GitHub Actions.
7
+
8
+ ## 5.0.3
9
+
10
+ ### Bug fix
11
+ * Fix for ActiveStorage::Attached::Many. [@enriquez](https://github.com/enriquez)
12
+
13
+ ## 5.0.2
14
+
15
+ ### Enhancements
16
+ * Remove instruction to use form-inline class. [@goalaleo](https://github.com/goalaleo)
17
+ * Added RichTextAreaInput for ActionText. [itsterry](https://github.com/itsterry)
18
+ * Skip valid_class check if no class defined. [TALlama](https://github.com/TALlama)
19
+
20
+ ### Bug fix
21
+ * Fix 'aria-required' field generated by prompt. [@CarlosAlbertoSantos](https://github.com/CarlosAlbertoSantos)
22
+
23
+ ## 5.0.1
24
+
25
+ ### Bug fix
26
+ * Replace `_url` with `remote_url` when trying to guess file inputs [@tegon](https://github.com/tegon). This has the side-effect of changing carrierwave's support from `0.2.1` to `0.2.2`.
27
+
28
+ ## 5.0.0
29
+
30
+ ### Enhancements
31
+ * Set multiple attribute for grouped selects also. [@ollym](https://github.com/ollym)
32
+ * Removes or renames label classes. [Abduvakilov](https://github.com/Abduvakilov)
33
+ * Support to label custom classes for inline collections. [@feliperenan](https://github.com/feliperenan)
34
+ * Update bootstrap generator template to match v4.3.x. [@m5o](https://github.com/m5o)
35
+ * Allow "required" attribute in generated select elements of PriorityInput. [@mcountis](https://github.com/mcountis)
36
+
37
+ ### Bug fix
38
+ * Do not call `#send` in form object to check whether the attribute is a file input. [@tegon](https://github.com/tegon)
39
+
40
+ ## Deprecations
41
+ * The config `SimpleForm.file_methods` is deprecated and it has no effect. Simple Form now supports automatically discover of file inputs for the following Gems: activestorage, carrierwave, paperclip, refile and shrine. If you are using a custom method that is not from one of the supported Gems, please change your forms to pass the input type explicitly:
42
+
43
+ ```erb
44
+ <%= form.input :avatar, as: :file %>
45
+ ```
46
+
47
+ See http://blog.plataformatec.com.br/2019/09/incorrect-access-control-in-simple-form-cve-2019-16676 for more information.
48
+
49
+ ## 4.1.0
2
50
 
3
51
  ### Enhancements
4
52
  * Guess input type more carefully. [@sringling](https://github.com/sringling)
5
53
  * Allow custom error on forms without model. [@victorperez](https://github.com/victorperez)
6
54
  * Do not support Ruby < 2.3 anymore. [@gssbzn](https://github.com/gssbzn)
7
- * Add color inout type. [@gssbzn](https://github.com/gssbzn)
55
+ * Add color input type. [@gssbzn](https://github.com/gssbzn)
8
56
 
9
57
  ### Bug fix
10
58
  * Improve disabled option to input_field. [@betelgeuse](https://github.com/betelgeuse)
@@ -84,7 +132,7 @@
84
132
 
85
133
  ### bug fix
86
134
  * Fix `merge_wrapper_options` to correctly merge options with duplicated keys. [@herminiotorres](https://github.com/herminiotorres)
87
- Closes [#1278](https://github.com/plataformatec/simple_form/issues/1278).
135
+ Closes [#1278](https://github.com/heartcombo/simple_form/issues/1278).
88
136
 
89
137
  ## 3.2.1
90
138
 
@@ -146,11 +194,11 @@
146
194
  * Add `boolean_label_class` config.
147
195
  * Add `:html` option to include additional attributes on custom wrappers [@remofritzsche](https://github.com/remofritzsche) and [@ulissesalmeida](https://github.com/ulissesalmeida)
148
196
  * Make possible to use the Wrappers API to define attributes for the components.
149
- See https://github.com/plataformatec/simple_form/pull/997 for more information.
197
+ See https://github.com/heartcombo/simple_form/pull/997 for more information.
150
198
  * Put a whitespace before the `inline_label` options of boolean input if it is present.
151
199
  * Add support to configure the `label_text` proc at the wrapper level. [@NOX73](https://github.com/NOX73)
152
200
  * `label_text` proc now receive three arguments (label, request, and if the label was explicit). [@timscott](https://github.com/timscott)
153
- * Add I18n support to `:include_blank` and `:prompt` when `:translate` is used as value. [@haines](https://github.com/plataformatec/simple_form/pull/616)
201
+ * Add I18n support to `:include_blank` and `:prompt` when `:translate` is used as value. [@haines](https://github.com/heartcombo/simple_form/pull/616)
154
202
  * Add support to define custom error messages for the attributes.
155
203
  * Add support to change the I18n scope to be used in Simple Form. [@nielsbuus](https://github.com/nielsbuus)
156
204
  * The default form class can now be overridden with `html: { :class }`. [@rmm5t](https://github.com/rmm5t)
@@ -159,16 +207,16 @@
159
207
  * Fix `full_error` when the attribute is an association. [@mvdamme](https://github.com/jorge-d)
160
208
  * Fix suppport to `:namespace` and `:index` options for nested check boxes and radio buttons when the attribute is an association.
161
209
  * Collection input that uses automatic collection translation properly sets checked values.
162
- Closes [#971](https://github.com/plataformatec/simple_form/issues/971) [@nashby](https://github.com/nashby)
210
+ Closes [#971](https://github.com/heartcombo/simple_form/issues/971) [@nashby](https://github.com/nashby)
163
211
  * Collection input generates `required` attribute if it has `prompt` option. [@nashby](https://github.com/nashby)
164
212
  * Grouped collection uses the first non-empty object to detect label and value methods.
165
213
 
166
214
  ## deprecation
167
215
  * Methods on custom inputs now accept a required argument with the wrapper options.
168
- See https://github.com/plataformatec/simple_form/pull/997 for more information.
216
+ See https://github.com/heartcombo/simple_form/pull/997 for more information.
169
217
  * SimpleForm.form_class is deprecated in favor of SimpleForm.default_form_class.
170
218
  Future versions of Simple Form will not generate `simple_form` class for the form
171
219
  element.
172
- See https://github.com/plataformatec/simple_form/pull/1109 for more information.
220
+ See https://github.com/heartcombo/simple_form/pull/1109 for more information.
173
221
 
174
- Please check [v3.0](https://github.com/plataformatec/simple_form/blob/v3.0/CHANGELOG.md) for previous changes.
222
+ Please check [v3.0](https://github.com/heartcombo/simple_form/blob/v3.0/CHANGELOG.md) for previous changes.
data/MIT-LICENSE CHANGED
@@ -1,4 +1,5 @@
1
- Copyright (c) 2009-2016 Plataformatec http://plataformatec.com.br/
1
+ Copyright (c) 2020 Rafael França, Carlos Antônio da Silva
2
+ Copyright (c) 2009-2019 Plataformatec
2
3
 
3
4
  Permission is hereby granted, free of charge, to any person obtaining
4
5
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,6 +1,4 @@
1
- ![Simple Form Logo](https://raw.github.com/plataformatec/simple_form/master/simple_form.png)
2
-
3
- By [Plataformatec](http://plataformatec.com.br/).
1
+ ![Simple Form Logo](https://raw.github.com/heartcombo/simple_form/master/simple_form.png)
4
2
 
5
3
  Rails forms made easy.
6
4
 
@@ -9,8 +7,7 @@ your forms. The basic goal of **Simple Form** is to not touch your way of defini
9
7
  you find the better design for your eyes. Most of the DSL was inherited from Formtastic,
10
8
  which we are thankful for and should make you feel right at home.
11
9
 
12
- INFO: This README is [also available in a friendly navigable format](http://simple-form.plataformatec.com.br/)
13
- and refers to **Simple Form** 3.1. For older releases, check the related branch for your version.
10
+ INFO: This README refers to **Simple Form** 5.0. For older releases, check the related branch for your version.
14
11
 
15
12
  ## Installation
16
13
 
@@ -118,7 +115,7 @@ of any of them:
118
115
 
119
116
  ```erb
120
117
  <%= simple_form_for @user do |f| %>
121
- <%= f.input :username, label_html: { class: 'my_class' } %>
118
+ <%= f.input :username, label_html: { class: 'my_class' }, hint_html: { class: 'hint_class' } %>
122
119
  <%= f.input :password, hint: false, error_html: { id: 'password_error'} %>
123
120
  <%= f.input :password_confirmation, label: false %>
124
121
  <%= f.button :submit %>
@@ -184,7 +181,7 @@ By default, **Simple Form** will look at the column type in the database and use
184
181
  appropriate input for the column. For example, a column created with type
185
182
  `:text` in the database will use a `textarea` input by default. See the section
186
183
  [Available input types and defaults for each column
187
- type](https://github.com/plataformatec/simple_form#available-input-types-and-defaults-for-each-column-type)
184
+ type](https://github.com/heartcombo/simple_form#available-input-types-and-defaults-for-each-column-type)
188
185
  for a complete list of defaults.
189
186
 
190
187
  **Simple Form** also lets you overwrite the default input type it creates:
@@ -288,14 +285,7 @@ end
288
285
  </form>
289
286
  ```
290
287
 
291
- Produces:
292
-
293
- ```html
294
- <input class="string required" id="user_name" maxlength="100"
295
- name="user[name]" size="100" type="text" value="Carlos" />
296
- ```
297
-
298
- To view the actual RDocs for this, check them out here - http://rubydoc.info/github/plataformatec/simple_form/master/SimpleForm/FormBuilder:input_field
288
+ To view the actual RDocs for this, check them out here - http://rubydoc.info/github/heartcombo/simple_form/master/SimpleForm/FormBuilder:input_field
299
289
 
300
290
  ### Collections
301
291
 
@@ -325,7 +315,7 @@ Collection inputs accept two other options beside collections:
325
315
  Those methods are useful to manipulate the given collection. Both of these options also accept
326
316
  lambda/procs in case you want to calculate the value or label in a special way eg. custom
327
317
  translation. You can also define a `to_label` method on your model as **Simple Form** will search for
328
- and use `:to_label` as a `:label_method` first if it is found.
318
+ and use `:to_label` as a `:label_method` first if it is found.
329
319
 
330
320
  By default, **Simple Form** will use the first item from an array as the label and the second one as the value.
331
321
  If you want to change this behavior you must make it explicit, like this:
@@ -507,7 +497,7 @@ Creates a collection of radio inputs with labels associated (same API as `collec
507
497
 
508
498
  ```ruby
509
499
  form_for @user do |f|
510
- f.collection_radio_buttons :options, [[true, 'Yes'] ,[false, 'No']], :first, :last
500
+ f.collection_radio_buttons :options, [[true, 'Yes'], [false, 'No']], :first, :last
511
501
  end
512
502
  ```
513
503
 
@@ -524,7 +514,7 @@ Creates a collection of checkboxes with labels associated (same API as `collecti
524
514
 
525
515
  ```ruby
526
516
  form_for @user do |f|
527
- f.collection_check_boxes :options, [[true, 'Yes'] ,[false, 'No']], :first, :last
517
+ f.collection_check_boxes :options, [[true, 'Yes'], [false, 'No']], :first, :last
528
518
  end
529
519
  ```
530
520
 
@@ -545,6 +535,12 @@ form_for @user do |f|
545
535
  end
546
536
  ```
547
537
 
538
+ To add a CSS class to the label item, you can use the `item_label_class` option:
539
+
540
+ ```ruby
541
+ f.collection_check_boxes :role_ids, Role.all, :id, :name, item_label_class: 'my-custom-class'
542
+ ```
543
+
548
544
  ## Available input types and defaults for each column type
549
545
 
550
546
  The following table shows the html element you will get for each attribute
@@ -562,6 +558,7 @@ Mapping | Generated HTML Element | Database Column Type
562
558
  `password` | `input[type=password]` | `string` with `name =~ /password/`
563
559
  `search` | `input[type=search]` | -
564
560
  `uuid` | `input[type=text]` | `uuid`
561
+ `color` | `input[type=color]` | `string`
565
562
  `text` | `textarea` | `text`
566
563
  `hstore` | `textarea` | `hstore`
567
564
  `json` | `textarea` | `json`
@@ -910,8 +907,8 @@ config.wrappers do |b|
910
907
  end
911
908
  ```
912
909
 
913
- This you set the input and label class to `'label-input-class'` and will set the class `'is-invalid'`
914
- when the input has errors and `'is-valid'` if the input is valid.
910
+ This sets the input and label classes to `'label-input-class'` and will set the class `'is-invalid'`
911
+ if the input has errors and `'is-valid'` if the input is valid.
915
912
 
916
913
  If you want to customize the custom _Form components_ on demand you can give it a name like this:
917
914
 
@@ -992,7 +989,7 @@ when the content is present.
992
989
 
993
990
  ## Custom Components
994
991
 
995
- When you use custom wrappers, you might also be looking for a way to add custom components to your
992
+ When you use custom wrappers, you might also be looking for a way to add custom components to your
996
993
  wrapper. The default components are:
997
994
 
998
995
  ```ruby
@@ -1143,8 +1140,8 @@ by passing the html5 option:
1143
1140
 
1144
1141
  ### Using non Active Record objects
1145
1142
 
1146
- There are few ways to build forms with objects that don't inherit from Active Record, as
1147
- follow:
1143
+ There are few ways to build forms with objects that don't inherit from Active Record, as
1144
+ follows:
1148
1145
 
1149
1146
  You can include the module `ActiveModel::Model`.
1150
1147
 
@@ -1156,14 +1153,14 @@ class User
1156
1153
  end
1157
1154
  ```
1158
1155
 
1159
- If you are using Presenters or Decorators that inherit from `SimpleDelegator` you can delegate
1156
+ If you are using Presenters or Decorators that inherit from `SimpleDelegator` you can delegate
1160
1157
  it to the model.
1161
1158
 
1162
1159
  ```ruby
1163
1160
  class UserPresenter < SimpleDelegator
1164
1161
  # Without that, Simple Form will consider the user model as the object.
1165
- def to_model
1166
- self
1162
+ def to_model
1163
+ self
1167
1164
  end
1168
1165
  end
1169
1166
  ```
@@ -1171,7 +1168,7 @@ end
1171
1168
  You can define all methods required by the helpers.
1172
1169
 
1173
1170
  ```ruby
1174
- class User
1171
+ class User
1175
1172
  extend ActiveModel::Naming
1176
1173
 
1177
1174
  attr_accessor :id, :name
@@ -1180,25 +1177,25 @@ class User
1180
1177
  self
1181
1178
  end
1182
1179
 
1183
- def to_key
1184
- id
1180
+ def to_key
1181
+ id
1185
1182
  end
1186
1183
 
1187
- def persisted?
1188
- false
1184
+ def persisted?
1185
+ false
1189
1186
  end
1190
1187
  end
1191
1188
  ```
1192
1189
 
1193
- If your object doesn't implement those methods, you must make explicit it when you are
1190
+ If your object doesn't implement those methods, you must make explicit it when you are
1194
1191
  building the form
1195
1192
 
1196
1193
  ```ruby
1197
- class User
1194
+ class User
1198
1195
  attr_accessor :id, :name
1199
1196
 
1200
1197
  # The only method required to use the f.submit helper.
1201
- def persisted?
1198
+ def persisted?
1202
1199
  false
1203
1200
  end
1204
1201
  end
@@ -1206,25 +1203,25 @@ end
1206
1203
 
1207
1204
  ```erb
1208
1205
  <%= simple_form_for(@user, as: :user, method: :post, url: users_path) do |f| %>
1209
- <%= f.input :name %>
1206
+ <%= f.input :name %>
1210
1207
  <%= f.submit 'New user' %>
1211
1208
  <% end %>
1212
1209
  ```
1213
1210
 
1214
1211
  ## Information
1215
1212
 
1216
- ### Google Group
1213
+ ### RDocs
1217
1214
 
1218
- If you have any questions, comments, or concerns please use the Google Group instead of the GitHub
1219
- Issues tracker:
1215
+ You can view the **Simple Form** documentation in RDoc format here:
1220
1216
 
1221
- http://groups.google.com/group/plataformatec-simpleform
1217
+ http://rubydoc.info/github/heartcombo/simple_form/master/frames
1222
1218
 
1223
- ### RDocs
1219
+ ### Supported Ruby / Rails versions
1224
1220
 
1225
- You can view the **Simple Form** documentation in RDoc format here:
1221
+ We intend to maintain support for all Ruby / Rails versions that haven't reached end-of-life.
1226
1222
 
1227
- http://rubydoc.info/github/plataformatec/simple_form/master/frames
1223
+ For more information about specific versions please check [Ruby](https://www.ruby-lang.org/en/downloads/branches/)
1224
+ and [Rails](https://guides.rubyonrails.org/maintenance_policy.html) maintenance policies, and our test matrix.
1228
1225
 
1229
1226
  ### Bug reports
1230
1227
 
@@ -1232,23 +1229,22 @@ If you discover any bugs, feel free to create an issue on GitHub. Please add as
1232
1229
  possible to help us in fixing the potential bug. We also encourage you to help even more by forking and
1233
1230
  sending us a pull request.
1234
1231
 
1235
- https://github.com/plataformatec/simple_form/issues
1232
+ https://github.com/heartcombo/simple_form/issues
1233
+
1234
+ If you have discovered a security related bug, please do NOT use the GitHub issue tracker. Send an e-mail to heartcombo@googlegroups.com.
1236
1235
 
1237
1236
  ## Maintainers
1238
1237
 
1239
- * José Valim (https://github.com/josevalim)
1240
1238
  * Carlos Antonio da Silva (https://github.com/carlosantoniodasilva)
1241
1239
  * Rafael Mendonça França (https://github.com/rafaelfranca)
1242
- * Vasiliy Ermolovich (https://github.com/nashby)
1240
+ * Felipe Renan (https://github.com/feliperenan)
1243
1241
 
1244
1242
  [![Gem Version](https://fury-badge.herokuapp.com/rb/simple_form.png)](http://badge.fury.io/rb/simple_form)
1245
- [![Build Status](https://api.travis-ci.org/plataformatec/simple_form.svg?branch=master)](http://travis-ci.org/plataformatec/simple_form)
1246
- [![Code Climate](https://codeclimate.com/github/plataformatec/simple_form.png)](https://codeclimate.com/github/plataformatec/simple_form)
1247
- [![Inline docs](http://inch-ci.org/github/plataformatec/simple_form.png)](http://inch-ci.org/github/plataformatec/simple_form)
1243
+ [![Code Climate](https://codeclimate.com/github/heartcombo/simple_form.png)](https://codeclimate.com/github/heartcombo/simple_form)
1244
+ [![Inline docs](http://inch-ci.org/github/heartcombo/simple_form.png)](http://inch-ci.org/github/heartcombo/simple_form)
1248
1245
 
1249
1246
  ## License
1250
1247
 
1251
- MIT License. Copyright 2009-2018 Plataformatec. http://plataformatec.com.br
1248
+ MIT License. Copyright 2020 Rafael França, Carlos Antônio da Silva. Copyright 2009-2019 Plataformatec.
1252
1249
 
1253
- You are not granted rights or licenses to the trademarks of the Plataformatec, including without
1254
- limitation the Simple Form name or logo.
1250
+ 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/).
@@ -3,9 +3,8 @@
3
3
  Be sure to have a copy of the Bootstrap stylesheet available on your
4
4
  application, you can get it on http://getbootstrap.com/.
5
5
 
6
- Inside your views, use the 'simple_form_for' with the Bootstrap form
7
- class, '.form-inline', as the following:
6
+ For usage examples and documentation, see:
8
7
 
9
- = simple_form_for(@user, html: { class: 'form-inline' }) do |form|
8
+ http://simple-form-bootstrap.plataformatec.com.br/
10
9
 
11
10
  ===============================================================================
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # Uncomment this and change the path if necessary to include your own
4
4
  # components.
5
- # See https://github.com/plataformatec/simple_form#custom-components to know
5
+ # See https://github.com/heartcombo/simple_form#custom-components to know
6
6
  # more about custom components.
7
7
  # Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
8
8
  #
@@ -129,9 +129,6 @@ SimpleForm.setup do |config|
129
129
  # change this configuration to true.
130
130
  config.browser_validations = false
131
131
 
132
- # Collection of methods to detect if a file type was given.
133
- # config.file_methods = [ :mounted_as, :file?, :public_filename, :attached? ]
134
-
135
132
  # Custom mappings for input types. This should be a hash containing a regexp
136
133
  # to match as key, and the input type that will be used when the field name
137
134
  # matches the regexp as value.
@@ -4,11 +4,11 @@
4
4
  # This generator is maintained by the community around simple_form-bootstrap:
5
5
  # https://github.com/rafaelfranca/simple_form-bootstrap
6
6
  # All future development, tests, and organization should happen there.
7
- # Background history: https://github.com/plataformatec/simple_form/issues/1561
7
+ # Background history: https://github.com/heartcombo/simple_form/issues/1561
8
8
 
9
9
  # Uncomment this and change the path if necessary to include your own
10
10
  # components.
11
- # See https://github.com/plataformatec/simple_form#custom-components
11
+ # See https://github.com/heartcombo/simple_form#custom-components
12
12
  # to know more about custom components.
13
13
  # Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
14
14
 
@@ -57,7 +57,7 @@ SimpleForm.setup do |config|
57
57
  b.optional :pattern
58
58
  b.optional :min_max
59
59
  b.optional :readonly
60
- b.use :label, class: 'form-control-label'
60
+ b.use :label
61
61
  b.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
62
62
  b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
63
63
  b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
@@ -76,7 +76,7 @@ SimpleForm.setup do |config|
76
76
  end
77
77
 
78
78
  # vertical input for radio buttons and check boxes
79
- config.wrappers :vertical_collection, item_wrapper_class: 'form-check', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
79
+ config.wrappers :vertical_collection, item_wrapper_class: 'form-check', item_label_class: 'form-check-label', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
80
80
  b.use :html5
81
81
  b.optional :readonly
82
82
  b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
@@ -88,7 +88,7 @@ SimpleForm.setup do |config|
88
88
  end
89
89
 
90
90
  # vertical input for inline radio buttons and check boxes
91
- config.wrappers :vertical_collection_inline, item_wrapper_class: 'form-check form-check-inline', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
91
+ config.wrappers :vertical_collection_inline, item_wrapper_class: 'form-check form-check-inline', item_label_class: 'form-check-label', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
92
92
  b.use :html5
93
93
  b.optional :readonly
94
94
  b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
@@ -108,7 +108,7 @@ SimpleForm.setup do |config|
108
108
  b.optional :readonly
109
109
  b.use :label
110
110
  b.use :input, class: 'form-control-file', error_class: 'is-invalid', valid_class: 'is-valid'
111
- b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
111
+ b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
112
112
  b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
113
113
  end
114
114
 
@@ -116,7 +116,7 @@ SimpleForm.setup do |config|
116
116
  config.wrappers :vertical_multi_select, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
117
117
  b.use :html5
118
118
  b.optional :readonly
119
- b.use :label, class: 'form-control-label'
119
+ b.use :label
120
120
  b.wrapper tag: 'div', class: 'd-flex flex-row justify-content-between align-items-center' do |ba|
121
121
  ba.use :input, class: 'form-control mx-1', error_class: 'is-invalid', valid_class: 'is-valid'
122
122
  end
@@ -174,10 +174,10 @@ SimpleForm.setup do |config|
174
174
  end
175
175
 
176
176
  # horizontal input for radio buttons and check boxes
177
- config.wrappers :horizontal_collection, item_wrapper_class: 'form-check', tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
177
+ config.wrappers :horizontal_collection, item_wrapper_class: 'form-check', item_label_class: 'form-check-label', tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
178
178
  b.use :html5
179
179
  b.optional :readonly
180
- b.use :label, class: 'col-sm-3 form-control-label'
180
+ b.use :label, class: 'col-sm-3 col-form-label pt-0'
181
181
  b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba|
182
182
  ba.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
183
183
  ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
@@ -186,10 +186,10 @@ SimpleForm.setup do |config|
186
186
  end
187
187
 
188
188
  # horizontal input for inline radio buttons and check boxes
189
- config.wrappers :horizontal_collection_inline, item_wrapper_class: 'form-check form-check-inline', tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
189
+ config.wrappers :horizontal_collection_inline, item_wrapper_class: 'form-check form-check-inline', item_label_class: 'form-check-label', tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
190
190
  b.use :html5
191
191
  b.optional :readonly
192
- b.use :label, class: 'col-sm-3 form-control-label'
192
+ b.use :label, class: 'col-sm-3 col-form-label pt-0'
193
193
  b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba|
194
194
  ba.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
195
195
  ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
@@ -204,7 +204,7 @@ SimpleForm.setup do |config|
204
204
  b.optional :maxlength
205
205
  b.optional :minlength
206
206
  b.optional :readonly
207
- b.use :label, class: 'col-sm-3 form-control-label'
207
+ b.use :label, class: 'col-sm-3 col-form-label'
208
208
  b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba|
209
209
  ba.use :input, error_class: 'is-invalid', valid_class: 'is-valid'
210
210
  ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
@@ -216,7 +216,7 @@ SimpleForm.setup do |config|
216
216
  config.wrappers :horizontal_multi_select, tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
217
217
  b.use :html5
218
218
  b.optional :readonly
219
- b.use :label, class: 'col-sm-3 control-label'
219
+ b.use :label, class: 'col-sm-3 col-form-label'
220
220
  b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba|
221
221
  ba.wrapper tag: 'div', class: 'd-flex flex-row justify-content-between align-items-center' do |bb|
222
222
  bb.use :input, class: 'form-control mx-1', error_class: 'is-invalid', valid_class: 'is-valid'
@@ -232,7 +232,7 @@ SimpleForm.setup do |config|
232
232
  b.use :placeholder
233
233
  b.optional :readonly
234
234
  b.optional :step
235
- b.use :label, class: 'col-sm-3 form-control-label'
235
+ b.use :label, class: 'col-sm-3 col-form-label'
236
236
  b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba|
237
237
  ba.use :input, class: 'form-control-range', error_class: 'is-invalid', valid_class: 'is-valid'
238
238
  ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
@@ -260,7 +260,7 @@ SimpleForm.setup do |config|
260
260
  end
261
261
 
262
262
  # inline input for boolean
263
- config.wrappers :inline_boolean, tag: 'span', class: 'form-check flex-wrap justify-content-start mr-sm-2', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
263
+ config.wrappers :inline_boolean, tag: 'span', class: 'form-check mb-2 mr-sm-2', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
264
264
  b.use :html5
265
265
  b.optional :readonly
266
266
  b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
@@ -284,10 +284,11 @@ SimpleForm.setup do |config|
284
284
  end
285
285
  end
286
286
 
287
+ # custom input switch for boolean
287
288
  config.wrappers :custom_boolean_switch, tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
288
289
  b.use :html5
289
290
  b.optional :readonly
290
- b.wrapper :form_check_wrapper, tag: 'div', class: 'custom-control custom-checkbox-switch' do |bb|
291
+ b.wrapper :form_check_wrapper, tag: 'div', class: 'custom-control custom-switch' do |bb|
291
292
  bb.use :input, class: 'custom-control-input', error_class: 'is-invalid', valid_class: 'is-valid'
292
293
  bb.use :label, class: 'custom-control-label'
293
294
  bb.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
@@ -296,7 +297,7 @@ SimpleForm.setup do |config|
296
297
  end
297
298
 
298
299
  # custom input for radio buttons and check boxes
299
- config.wrappers :custom_collection, item_wrapper_class: 'custom-control', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
300
+ config.wrappers :custom_collection, item_wrapper_class: 'custom-control', item_label_class: 'custom-control-label', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
300
301
  b.use :html5
301
302
  b.optional :readonly
302
303
  b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
@@ -308,7 +309,7 @@ SimpleForm.setup do |config|
308
309
  end
309
310
 
310
311
  # custom input for inline radio buttons and check boxes
311
- config.wrappers :custom_collection_inline, item_wrapper_class: 'custom-control custom-control-inline', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
312
+ config.wrappers :custom_collection_inline, item_wrapper_class: 'custom-control custom-control-inline', item_label_class: 'custom-control-label', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
312
313
  b.use :html5
313
314
  b.optional :readonly
314
315
  b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
@@ -326,7 +327,7 @@ SimpleForm.setup do |config|
326
327
  b.optional :maxlength
327
328
  b.optional :minlength
328
329
  b.optional :readonly
329
- b.use :label, class: 'form-control-label'
330
+ b.use :label
330
331
  b.wrapper :custom_file_wrapper, tag: 'div', class: 'custom-file' do |ba|
331
332
  ba.use :input, class: 'custom-file-input', error_class: 'is-invalid', valid_class: 'is-valid'
332
333
  ba.use :label, class: 'custom-file-label'
@@ -339,7 +340,7 @@ SimpleForm.setup do |config|
339
340
  config.wrappers :custom_multi_select, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
340
341
  b.use :html5
341
342
  b.optional :readonly
342
- b.use :label, class: 'form-control-label'
343
+ b.use :label
343
344
  b.wrapper tag: 'div', class: 'd-flex flex-row justify-content-between align-items-center' do |ba|
344
345
  ba.use :input, class: 'custom-select mx-1', error_class: 'is-invalid', valid_class: 'is-valid'
345
346
  end
@@ -353,7 +354,7 @@ SimpleForm.setup do |config|
353
354
  b.use :placeholder
354
355
  b.optional :readonly
355
356
  b.optional :step
356
- b.use :label, class: 'form-control-label'
357
+ b.use :label
357
358
  b.use :input, class: 'custom-range', error_class: 'is-invalid', valid_class: 'is-valid'
358
359
  b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
359
360
  b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
@@ -370,7 +371,7 @@ SimpleForm.setup do |config|
370
371
  # b.optional :pattern
371
372
  # b.optional :min_max
372
373
  # b.optional :readonly
373
- # b.use :label, class: 'form-control-label'
374
+ # b.use :label
374
375
  # b.wrapper :input_group_tag, tag: 'div', class: 'input-group' do |ba|
375
376
  # ba.optional :prepend
376
377
  # ba.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
@@ -393,7 +394,7 @@ SimpleForm.setup do |config|
393
394
  b.optional :min_max
394
395
  b.optional :readonly
395
396
  b.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
396
- b.use :label, class: 'form-control-label'
397
+ b.use :label
397
398
  b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
398
399
  b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
399
400
  end
@@ -402,8 +403,8 @@ SimpleForm.setup do |config|
402
403
  config.wrappers :floating_labels_select, tag: 'div', class: 'form-label-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
403
404
  b.use :html5
404
405
  b.optional :readonly
405
- b.use :input, class: 'custom-select custom-select-lg', error_class: 'is-invalid', valid_class: 'is-valid'
406
- b.use :label, class: 'form-control-label'
406
+ b.use :input, class: 'custom-select', error_class: 'is-invalid', valid_class: 'is-valid'
407
+ b.use :label
407
408
  b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
408
409
  b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
409
410
  end