simple_form 5.0.3 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/README.md +69 -15
- data/lib/generators/simple_form/install_generator.rb +2 -2
- data/lib/generators/simple_form/templates/README +1 -1
- data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +1 -1
- data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +126 -194
- data/lib/simple_form/components/labels.rb +3 -5
- data/lib/simple_form/components/maxlength.rb +0 -4
- data/lib/simple_form/components/minlength.rb +0 -4
- data/lib/simple_form/form_builder.rb +1 -1
- data/lib/simple_form/inputs/base.rb +0 -3
- data/lib/simple_form/inputs/boolean_input.rb +6 -2
- data/lib/simple_form/inputs/collection_input.rb +2 -4
- data/lib/simple_form/inputs/grouped_collection_select_input.rb +1 -1
- data/lib/simple_form/inputs/priority_input.rb +16 -2
- data/lib/simple_form/version.rb +1 -1
- data/lib/simple_form.rb +1 -1
- data/test/components/label_test.rb +0 -4
- data/test/form_builder/wrapper_test.rb +2 -2
- data/test/inputs/boolean_input_test.rb +13 -0
- data/test/inputs/collection_check_boxes_input_test.rb +0 -4
- data/test/inputs/collection_radio_buttons_input_test.rb +0 -4
- data/test/inputs/collection_select_input_test.rb +0 -4
- data/test/inputs/country_input_test.rb +36 -0
- data/test/inputs/grouped_collection_select_input_test.rb +13 -0
- data/test/inputs/{priority_input_test.rb → time_zone_input_test.rb} +5 -19
- metadata +45 -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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ad9e2ec1c9f339ea03d225a1dc971adea0fb60efc571cd40655b7738eff273f
|
4
|
+
data.tar.gz: 937cee947cb4432fea02ff967879356442721bed0e01cb0c4fa3e9f50626a2cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf3e4b076014b076ff2168a0a1d236e21fbdf631ea0198d9e6a3b86eff908de1068f8a0f972fa7f4f9990ca3e3f7ae1d63a762b53f9975cebbd71e4f1a5a233e
|
7
|
+
data.tar.gz: a0a12ac9760afd5ade06c4a26942adbe515570947b0ae1eb7889fb0d626e2e57b177e82e32a02346ec0fe23591ce74cd609f669892df0d9969ae8b858562ec91
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
## Unreleased
|
2
|
+
|
3
|
+
|
4
|
+
## 5.2.0
|
5
|
+
|
6
|
+
* Add support for Rails 7.0 and Ruby 3.1/3.2 (no changes required)
|
7
|
+
* Fix escaping issue on boolean input with `include_hidden: false` and custom wrapper.
|
8
|
+
* Update Bootstrap install generator version 5. [@mhw](https://github.com/mhw)
|
9
|
+
* Accept proc as `group_method` for grouped collection select
|
10
|
+
* Honor `include_hidden` option on inline boolean inputs [@yboulkaid](https://github.com/yboulkaid)
|
11
|
+
* Fix deprecation error when using country_select input.
|
12
|
+
|
13
|
+
## 5.1.0
|
14
|
+
|
15
|
+
* 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.
|
16
|
+
* Add support for Ruby 3.0, drop support for Ruby < 2.5.
|
17
|
+
* Add support for Rails 6.1, drop support for Rails < 5.2.
|
18
|
+
* Move CI to GitHub Actions.
|
19
|
+
|
1
20
|
## 5.0.3
|
2
21
|
|
3
22
|
### Bug fix
|
data/README.md
CHANGED
@@ -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
|
35
|
-
|
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/
|
46
|
-
[the live example app](
|
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:
|
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/
|
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
|
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
|
-
|
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,14 @@ 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/
|
1266
|
+
http://rubydoc.info/github/heartcombo/simple_form/main/frames
|
1267
|
+
|
1268
|
+
### Supported Ruby / Rails versions
|
1269
|
+
|
1270
|
+
We intend to maintain support for all Ruby / Rails versions that haven't reached end-of-life.
|
1271
|
+
|
1272
|
+
For more information about specific versions please check [Ruby](https://www.ruby-lang.org/en/downloads/branches/)
|
1273
|
+
and [Rails](https://guides.rubyonrails.org/maintenance_policy.html) maintenance policies, and our test matrix.
|
1218
1274
|
|
1219
1275
|
### Bug reports
|
1220
1276
|
|
@@ -1233,7 +1289,6 @@ If you have discovered a security related bug, please do NOT use the GitHub issu
|
|
1233
1289
|
* Felipe Renan (https://github.com/feliperenan)
|
1234
1290
|
|
1235
1291
|
[![Gem Version](https://fury-badge.herokuapp.com/rb/simple_form.png)](http://badge.fury.io/rb/simple_form)
|
1236
|
-
[![Build Status](https://api.travis-ci.org/heartcombo/simple_form.svg?branch=master)](http://travis-ci.org/heartcombo/simple_form)
|
1237
1292
|
[![Code Climate](https://codeclimate.com/github/heartcombo/simple_form.png)](https://codeclimate.com/github/heartcombo/simple_form)
|
1238
1293
|
[![Inline docs](http://inch-ci.org/github/heartcombo/simple_form.png)](http://inch-ci.org/github/heartcombo/simple_form)
|
1239
1294
|
|
@@ -1242,4 +1297,3 @@ If you have discovered a security related bug, please do NOT use the GitHub issu
|
|
1242
1297
|
MIT License. Copyright 2020 Rafael França, Carlos Antônio da Silva. Copyright 2009-2019 Plataformatec.
|
1243
1298
|
|
1244
1299
|
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/).
|
1245
|
-
|
@@ -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
|
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
|
@@ -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
|
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
|
|