simple_form 4.0.1 → 5.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +61 -8
  3. data/MIT-LICENSE +2 -1
  4. data/README.md +43 -52
  5. data/lib/generators/simple_form/templates/README +2 -3
  6. data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +1 -7
  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/errors.rb +5 -1
  11. data/lib/simple_form/form_builder.rb +30 -10
  12. data/lib/simple_form/inputs.rb +2 -0
  13. data/lib/simple_form/inputs/base.rb +4 -1
  14. data/lib/simple_form/inputs/boolean_input.rb +1 -0
  15. data/lib/simple_form/inputs/collection_check_boxes_input.rb +1 -1
  16. data/lib/simple_form/inputs/collection_input.rb +1 -1
  17. data/lib/simple_form/inputs/color_input.rb +14 -0
  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/inputs/string_input.rb +1 -1
  21. data/lib/simple_form/tags.rb +6 -2
  22. data/lib/simple_form/version.rb +1 -1
  23. data/lib/simple_form/wrappers/root.rb +8 -3
  24. data/test/action_view_extensions/builder_test.rb +22 -4
  25. data/test/form_builder/association_test.rb +6 -0
  26. data/test/form_builder/error_test.rb +6 -0
  27. data/test/form_builder/general_test.rb +23 -19
  28. data/test/form_builder/input_field_test.rb +3 -9
  29. data/test/form_builder/label_test.rb +1 -1
  30. data/test/form_builder/wrapper_test.rb +8 -1
  31. data/test/inputs/boolean_input_test.rb +8 -0
  32. data/test/inputs/collection_check_boxes_input_test.rb +8 -0
  33. data/test/inputs/collection_radio_buttons_input_test.rb +8 -0
  34. data/test/inputs/collection_select_input_test.rb +6 -0
  35. data/test/inputs/color_input_test.rb +10 -0
  36. data/test/inputs/datetime_input_test.rb +2 -12
  37. data/test/inputs/disabled_test.rb +13 -0
  38. data/test/inputs/discovery_test.rb +21 -0
  39. data/test/inputs/priority_input_test.rb +6 -14
  40. data/test/inputs/rich_text_area_input_test.rb +15 -0
  41. data/test/inputs/string_input_test.rb +8 -15
  42. data/test/support/discovery_inputs.rb +7 -0
  43. data/test/support/misc_helpers.rb +8 -2
  44. data/test/support/models.rb +29 -6
  45. data/test/test_helper.rb +7 -4
  46. metadata +40 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 36ca6e532e2f506a2946b385aa3137f28d1fb6bb
4
- data.tar.gz: b24a8f5bd77dcab385219132ccb6216376299ba2
2
+ SHA256:
3
+ metadata.gz: 184b100fac3f2109461f1678b8a7fc1d0691e285946a5c2395bcba13a90ac4cd
4
+ data.tar.gz: bd14c6e07ab469e8d8df1822545c0707231412d10b18eaa00c1bfd015dfee4d5
5
5
  SHA512:
6
- metadata.gz: fe6cabc6ab3f055f83bcd6ab214f5cc8f9593aa0b1231fdf87deb8ffc612c3b6fab1d76d493a2cd9e9c1fad28b1d259a350160aaf0b1b58e712bb49f60b67646
7
- data.tar.gz: '008c90e740e05c719fdd4dfe1357c4ec6036c356f3746f813993696c8d849ef8f0122bfdbaa153cc93a12d9de9496efe32be7e72073d614969634448f139b30d'
6
+ metadata.gz: 99a5a7a83a866c5582d413b49ef6a5c14571b943e0e3c8a72b88084e24b91d46aa04f308566ce9aae0b6a6e7475e747f08fb82945f6f4122da84f9b0672c95d0
7
+ data.tar.gz: c6ae34fe070436f81a1cd79c18a359853e3a3dab4b5413c302011d82623d523e6c4826f44b4b58b59d1faddf319e3dae1da835d55e6c756f93cae4195d403e42
@@ -1,4 +1,57 @@
1
- ## Unreleased
1
+ ## 5.0.3
2
+
3
+ ### Bug fix
4
+ * Fix for ActiveStorage::Attached::Many. [@enriquez](https://github.com/enriquez)
5
+
6
+ ## 5.0.2
7
+
8
+ ### Enhancements
9
+ * Remove instruction to use form-inline class. [@goalaleo](https://github.com/goalaleo)
10
+ * Added RichTextAreaInput for ActionText. [itsterry](https://github.com/itsterry)
11
+ * Skip valid_class check if no class defined. [TALlama](https://github.com/TALlama)
12
+
13
+ ### Bug fix
14
+ * Fix 'aria-required' field generated by prompt. [@CarlosAlbertoSantos](https://github.com/CarlosAlbertoSantos)
15
+
16
+ ## 5.0.1
17
+
18
+ ### Bug fix
19
+ * 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`.
20
+
21
+ ## 5.0.0
22
+
23
+ ### Enhancements
24
+ * Set multiple attribute for grouped selects also. [@ollym](https://github.com/ollym)
25
+ * Removes or renames label classes. [Abduvakilov](https://github.com/Abduvakilov)
26
+ * Support to label custom classes for inline collections. [@feliperenan](https://github.com/feliperenan)
27
+ * Update bootstrap generator template to match v4.3.x. [@m5o](https://github.com/m5o)
28
+ * Allow "required" attribute in generated select elements of PriorityInput. [@mcountis](https://github.com/mcountis)
29
+
30
+ ### Bug fix
31
+ * Do not call `#send` in form object to check whether the attribute is a file input. [@tegon](https://github.com/tegon)
32
+
33
+ ## Deprecations
34
+ * 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:
35
+
36
+ ```erb
37
+ <%= form.input :avatar, as: :file %>
38
+ ```
39
+
40
+ See http://blog.plataformatec.com.br/2019/09/incorrect-access-control-in-simple-form-cve-2019-16676 for more information.
41
+
42
+ ## 4.1.0
43
+
44
+ ### Enhancements
45
+ * Guess input type more carefully. [@sringling](https://github.com/sringling)
46
+ * Allow custom error on forms without model. [@victorperez](https://github.com/victorperez)
47
+ * Do not support Ruby < 2.3 anymore. [@gssbzn](https://github.com/gssbzn)
48
+ * Add color input type. [@gssbzn](https://github.com/gssbzn)
49
+
50
+ ### Bug fix
51
+ * Improve disabled option to input_field. [@betelgeuse](https://github.com/betelgeuse)
52
+ * Memoize `input_html_classes` in `SimpleForm::Inputs::Base`. [@RigoTheDev](https://github.com/RigoTheDev)
53
+ * Fix column type citext HTML5 input type bug. [@brucew](https://github.com/brucew)
54
+ * Use form attribute in the nested boolean hidden field when it is given. [@feliperenan](https://github.com/feliperenan)
2
55
 
3
56
  ## 4.0.1
4
57
 
@@ -72,7 +125,7 @@
72
125
 
73
126
  ### bug fix
74
127
  * Fix `merge_wrapper_options` to correctly merge options with duplicated keys. [@herminiotorres](https://github.com/herminiotorres)
75
- Closes [#1278](https://github.com/plataformatec/simple_form/issues/1278).
128
+ Closes [#1278](https://github.com/heartcombo/simple_form/issues/1278).
76
129
 
77
130
  ## 3.2.1
78
131
 
@@ -134,11 +187,11 @@
134
187
  * Add `boolean_label_class` config.
135
188
  * Add `:html` option to include additional attributes on custom wrappers [@remofritzsche](https://github.com/remofritzsche) and [@ulissesalmeida](https://github.com/ulissesalmeida)
136
189
  * Make possible to use the Wrappers API to define attributes for the components.
137
- See https://github.com/plataformatec/simple_form/pull/997 for more information.
190
+ See https://github.com/heartcombo/simple_form/pull/997 for more information.
138
191
  * Put a whitespace before the `inline_label` options of boolean input if it is present.
139
192
  * Add support to configure the `label_text` proc at the wrapper level. [@NOX73](https://github.com/NOX73)
140
193
  * `label_text` proc now receive three arguments (label, request, and if the label was explicit). [@timscott](https://github.com/timscott)
141
- * Add I18n support to `:include_blank` and `:prompt` when `:translate` is used as value. [@haines](https://github.com/plataformatec/simple_form/pull/616)
194
+ * Add I18n support to `:include_blank` and `:prompt` when `:translate` is used as value. [@haines](https://github.com/heartcombo/simple_form/pull/616)
142
195
  * Add support to define custom error messages for the attributes.
143
196
  * Add support to change the I18n scope to be used in Simple Form. [@nielsbuus](https://github.com/nielsbuus)
144
197
  * The default form class can now be overridden with `html: { :class }`. [@rmm5t](https://github.com/rmm5t)
@@ -147,16 +200,16 @@
147
200
  * Fix `full_error` when the attribute is an association. [@mvdamme](https://github.com/jorge-d)
148
201
  * Fix suppport to `:namespace` and `:index` options for nested check boxes and radio buttons when the attribute is an association.
149
202
  * Collection input that uses automatic collection translation properly sets checked values.
150
- Closes [#971](https://github.com/plataformatec/simple_form/issues/971) [@nashby](https://github.com/nashby)
203
+ Closes [#971](https://github.com/heartcombo/simple_form/issues/971) [@nashby](https://github.com/nashby)
151
204
  * Collection input generates `required` attribute if it has `prompt` option. [@nashby](https://github.com/nashby)
152
205
  * Grouped collection uses the first non-empty object to detect label and value methods.
153
206
 
154
207
  ## deprecation
155
208
  * Methods on custom inputs now accept a required argument with the wrapper options.
156
- See https://github.com/plataformatec/simple_form/pull/997 for more information.
209
+ See https://github.com/heartcombo/simple_form/pull/997 for more information.
157
210
  * SimpleForm.form_class is deprecated in favor of SimpleForm.default_form_class.
158
211
  Future versions of Simple Form will not generate `simple_form` class for the form
159
212
  element.
160
- See https://github.com/plataformatec/simple_form/pull/1109 for more information.
213
+ See https://github.com/heartcombo/simple_form/pull/1109 for more information.
161
214
 
162
- Please check [v3.0](https://github.com/plataformatec/simple_form/blob/v3.0/CHANGELOG.md) for previous changes.
215
+ Please check [v3.0](https://github.com/heartcombo/simple_form/blob/v3.0/CHANGELOG.md) for previous changes.
@@ -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,18 @@ 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
1217
-
1218
- If you have any questions, comments, or concerns please use the Google Group instead of the GitHub
1219
- Issues tracker:
1220
-
1221
- http://groups.google.com/group/plataformatec-simpleform
1222
-
1223
1213
  ### RDocs
1224
1214
 
1225
1215
  You can view the **Simple Form** documentation in RDoc format here:
1226
1216
 
1227
- http://rubydoc.info/github/plataformatec/simple_form/master/frames
1217
+ http://rubydoc.info/github/heartcombo/simple_form/master/frames
1228
1218
 
1229
1219
  ### Bug reports
1230
1220
 
@@ -1232,23 +1222,24 @@ If you discover any bugs, feel free to create an issue on GitHub. Please add as
1232
1222
  possible to help us in fixing the potential bug. We also encourage you to help even more by forking and
1233
1223
  sending us a pull request.
1234
1224
 
1235
- https://github.com/plataformatec/simple_form/issues
1225
+ https://github.com/heartcombo/simple_form/issues
1226
+
1227
+ 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
1228
 
1237
1229
  ## Maintainers
1238
1230
 
1239
- * José Valim (https://github.com/josevalim)
1240
1231
  * Carlos Antonio da Silva (https://github.com/carlosantoniodasilva)
1241
1232
  * Rafael Mendonça França (https://github.com/rafaelfranca)
1242
- * Vasiliy Ermolovich (https://github.com/nashby)
1233
+ * Felipe Renan (https://github.com/feliperenan)
1243
1234
 
1244
1235
  [![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)
1236
+ [![Build Status](https://api.travis-ci.org/heartcombo/simple_form.svg?branch=master)](http://travis-ci.org/heartcombo/simple_form)
1237
+ [![Code Climate](https://codeclimate.com/github/heartcombo/simple_form.png)](https://codeclimate.com/github/heartcombo/simple_form)
1238
+ [![Inline docs](http://inch-ci.org/github/heartcombo/simple_form.png)](http://inch-ci.org/github/heartcombo/simple_form)
1248
1239
 
1249
1240
  ## License
1250
1241
 
1251
- MIT License. Copyright 2009-2018 Plataformatec. http://plataformatec.com.br
1242
+ MIT License. Copyright 2020 Rafael França, Carlos Antônio da Silva. Copyright 2009-2019 Plataformatec.
1243
+
1244
+ 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/).
1252
1245
 
1253
- You are not granted rights or licenses to the trademarks of the Plataformatec, including without
1254
- limitation the Simple Form name or logo.
@@ -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
  #
@@ -87,9 +87,6 @@ SimpleForm.setup do |config|
87
87
  # CSS class to add for error notification helper.
88
88
  config.error_notification_class = 'error_notification'
89
89
 
90
- # ID to add for error notification helper.
91
- # config.error_notification_id = nil
92
-
93
90
  # Series of attempts to detect a default label method for collection.
94
91
  # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
95
92
 
@@ -132,9 +129,6 @@ SimpleForm.setup do |config|
132
129
  # change this configuration to true.
133
130
  config.browser_validations = false
134
131
 
135
- # Collection of methods to detect if a file type was given.
136
- # config.file_methods = [ :mounted_as, :file?, :public_filename, :attached? ]
137
-
138
132
  # Custom mappings for input types. This should be a hash containing a regexp
139
133
  # to match as key, and the input type that will be used when the field name
140
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