simple_form 5.3.1 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -3
- data/MIT-LICENSE +1 -1
- data/README.md +48 -12
- data/lib/simple_form/components/html5.rb +0 -7
- data/lib/simple_form/components/labels.rb +1 -1
- data/lib/simple_form/form_builder.rb +6 -2
- data/lib/simple_form/inputs/rich_text_area_input.rb +2 -0
- data/lib/simple_form/inputs/weekday_input.rb +14 -0
- data/lib/simple_form/inputs.rb +1 -0
- data/lib/simple_form/version.rb +1 -1
- data/lib/simple_form.rb +3 -3
- metadata +39 -13
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ff2bd28ca5c8e4588daf7186c1f6e251bdfe463631da20c80afc9b3586dc52be
|
|
4
|
+
data.tar.gz: 304fdd3acf41d26dd2a02d1b1f301485956851582bab406069ad70d805157eea
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 57766d87e4fe98416ef41c7a2e30e32f8f91c3b0e5640b64afb4186b9c1e0e6730528c7f3a0b2079ace45d2b3fb8e936e47308324d57d6c2e0bf1db9e34043b1
|
|
7
|
+
data.tar.gz: ee60f97f3e42d518e3a37dfcd324d4020b16da685a151e6329aadb8a84747707e89ea8b9801729ef55974bf7965c9cecf65070f1598ebc10ccc990dd9b1bebc6
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
## Unreleased
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
* Add support for Ruby 3.4 and Rails 7.2/8.0/8.1. (no changes required)
|
|
4
|
+
* Drop support for Rails < 7 and Ruby < 2.7.
|
|
5
|
+
* Add `weekday` input. [#1846](https://github.com/heartcombo/simple_form/pull/1846)
|
|
6
|
+
* Remove redundant `aria-required` attribute for required fields. [#1823](https://github.com/heartcombo/simple_form/pull/1823)
|
|
7
|
+
* Integrate `:rich_text_area` with placeholders [#1842](https://github.com/heartcombo/simple_form/pull/1842)
|
|
8
|
+
* Fix encrypted attributes improperly casted (later fixed in Rails) [#1836](https://github.com/heartcombo/simple_form/pull/1836)
|
|
9
|
+
* Pass `base` object to `human_attribute_name` in labels [#1812](https://github.com/heartcombo/simple_form/pull/1812)
|
|
4
10
|
|
|
5
11
|
## 5.3.1
|
|
6
12
|
|
|
@@ -109,7 +115,7 @@ See http://blog.plataformatec.com.br/2019/09/incorrect-access-control-in-simple-
|
|
|
109
115
|
### Bug fix
|
|
110
116
|
* Fix horizontal form label position, from right to text-right. [@cavpollo](https://github.com/cavpollo)
|
|
111
117
|
* Add base error display alongside existing errors. [@bluefalcon26](https://github.com/bluefalcon26)
|
|
112
|
-
* Silent
|
|
118
|
+
* Silent deprecation warning for placeholder_text. [@moofkit](https://github.com/moofkit)
|
|
113
119
|
* Use custom i18n scope for label required html. [@tvdeyen](https://github.com/tvdeyen)
|
|
114
120
|
|
|
115
121
|
## 3.5.1
|
|
@@ -231,7 +237,7 @@ See http://blog.plataformatec.com.br/2019/09/incorrect-access-control-in-simple-
|
|
|
231
237
|
|
|
232
238
|
### bug fix
|
|
233
239
|
* Fix `full_error` when the attribute is an association. [@mvdamme](https://github.com/jorge-d)
|
|
234
|
-
* Fix
|
|
240
|
+
* Fix support to `:namespace` and `:index` options for nested check boxes and radio buttons when the attribute is an association.
|
|
235
241
|
* Collection input that uses automatic collection translation properly sets checked values.
|
|
236
242
|
Closes [#971](https://github.com/heartcombo/simple_form/issues/971) [@nashby](https://github.com/nashby)
|
|
237
243
|
* Collection input generates `required` attribute if it has `prompt` option. [@nashby](https://github.com/nashby)
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
|
+
[](http://badge.fury.io/rb/simple_form)
|
|
4
|
+
|
|
3
5
|
Rails forms made easy.
|
|
4
6
|
|
|
5
7
|
**Simple Form** aims to be as flexible as possible while helping you with powerful components to create
|
|
@@ -621,11 +623,13 @@ Mapping | Generated HTML Element | Database Column Type
|
|
|
621
623
|
`datetime` | `datetime select` | `datetime/timestamp`
|
|
622
624
|
`date` | `date select` | `date`
|
|
623
625
|
`time` | `time select` | `time`
|
|
626
|
+
`weekday` | `select` (weekdays as options) | -
|
|
624
627
|
`select` | `select` | `belongs_to`/`has_many`/`has_and_belongs_to_many` associations
|
|
625
628
|
`radio_buttons` | collection of `input[type=radio]` | `belongs_to` associations
|
|
626
629
|
`check_boxes` | collection of `input[type=checkbox]` | `has_many`/`has_and_belongs_to_many` associations
|
|
627
630
|
`country` | `select` (countries as options) | `string` with `name =~ /country/`
|
|
628
631
|
`time_zone` | `select` (timezones as options) | `string` with `name =~ /time_zone/`
|
|
632
|
+
`rich_text_area`| `trix-editor` | -
|
|
629
633
|
|
|
630
634
|
## Custom inputs
|
|
631
635
|
|
|
@@ -1187,7 +1191,7 @@ by passing the html5 option:
|
|
|
1187
1191
|
<%= f.input :expires_at, as: :date, html5: true %>
|
|
1188
1192
|
```
|
|
1189
1193
|
|
|
1190
|
-
|
|
1194
|
+
## Using non Active Record objects
|
|
1191
1195
|
|
|
1192
1196
|
There are few ways to build forms with objects that don't inherit from Active Record, as
|
|
1193
1197
|
follows:
|
|
@@ -1236,6 +1240,45 @@ class User
|
|
|
1236
1240
|
end
|
|
1237
1241
|
```
|
|
1238
1242
|
|
|
1243
|
+
To have SimpleForm infer the attributes' types, you can provide
|
|
1244
|
+
`#has_attribute?` and `#type_for_attribute` methods.
|
|
1245
|
+
The later should return an object that responds to `#type`
|
|
1246
|
+
with the attribute type. This is useful for generating
|
|
1247
|
+
the correct input types (eg: checkboxes for booleans).
|
|
1248
|
+
|
|
1249
|
+
```ruby
|
|
1250
|
+
class User < Struct.new(:id, :name, :age, :registered)
|
|
1251
|
+
def to_model
|
|
1252
|
+
self
|
|
1253
|
+
end
|
|
1254
|
+
|
|
1255
|
+
def model_name
|
|
1256
|
+
OpenStruct.new(param_key: "user")
|
|
1257
|
+
end
|
|
1258
|
+
|
|
1259
|
+
def to_key
|
|
1260
|
+
id
|
|
1261
|
+
end
|
|
1262
|
+
|
|
1263
|
+
def persisted?
|
|
1264
|
+
id.present?
|
|
1265
|
+
end
|
|
1266
|
+
|
|
1267
|
+
def has_attribute?(attr_name)
|
|
1268
|
+
%w(id name age registered).include?(attr_name.to_s)
|
|
1269
|
+
end
|
|
1270
|
+
|
|
1271
|
+
def type_for_attribute(attr_name)
|
|
1272
|
+
case attr_name.to_s
|
|
1273
|
+
when "id" then OpenStruct.new(type: :integer)
|
|
1274
|
+
when "name" then OpenStruct.new(type: :string)
|
|
1275
|
+
when "age" then OpenStruct.new(type: :integer)
|
|
1276
|
+
when "registered" then OpenStruct.new(type: :boolean)
|
|
1277
|
+
end
|
|
1278
|
+
end
|
|
1279
|
+
end
|
|
1280
|
+
```
|
|
1281
|
+
|
|
1239
1282
|
If your object doesn't implement those methods, you must make explicit it when you are
|
|
1240
1283
|
building the form
|
|
1241
1284
|
|
|
@@ -1280,19 +1323,12 @@ sending us a pull request.
|
|
|
1280
1323
|
|
|
1281
1324
|
https://github.com/heartcombo/simple_form/issues
|
|
1282
1325
|
|
|
1283
|
-
If you have discovered a security related bug, please do NOT use the GitHub issue tracker. Send an e-mail to heartcombo@
|
|
1284
|
-
|
|
1285
|
-
## Maintainers
|
|
1286
|
-
|
|
1287
|
-
* Carlos Antonio da Silva (https://github.com/carlosantoniodasilva)
|
|
1288
|
-
* Rafael Mendonça França (https://github.com/rafaelfranca)
|
|
1289
|
-
* Felipe Renan (https://github.com/feliperenan)
|
|
1290
|
-
|
|
1291
|
-
[](http://badge.fury.io/rb/simple_form)
|
|
1292
|
-
[](http://inch-ci.org/github/heartcombo/simple_form)
|
|
1326
|
+
If you have discovered a security related bug, please do NOT use the GitHub issue tracker. Send an e-mail to heartcombo.oss@gmail.com.
|
|
1293
1327
|
|
|
1294
1328
|
## License
|
|
1295
1329
|
|
|
1296
|
-
MIT License.
|
|
1330
|
+
MIT License.
|
|
1331
|
+
Copyright 2020-2025 Rafael França, Carlos Antonio da Silva.
|
|
1332
|
+
Copyright 2009-2019 Plataformatec.
|
|
1297
1333
|
|
|
1298
1334
|
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/).
|
|
@@ -10,10 +10,7 @@ module SimpleForm
|
|
|
10
10
|
@html5 = true
|
|
11
11
|
|
|
12
12
|
input_html_options[:required] = input_html_required_option
|
|
13
|
-
input_html_options[:'aria-required'] = input_html_aria_required_option
|
|
14
|
-
|
|
15
13
|
input_html_options[:'aria-invalid'] = has_errors? || nil
|
|
16
|
-
|
|
17
14
|
nil
|
|
18
15
|
end
|
|
19
16
|
|
|
@@ -25,10 +22,6 @@ module SimpleForm
|
|
|
25
22
|
!options[:required].nil? ? required_field? : has_required?
|
|
26
23
|
end
|
|
27
24
|
|
|
28
|
-
def input_html_aria_required_option
|
|
29
|
-
!options[:required].nil? ? (required_field? || nil) : (has_required? || nil)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
25
|
def has_required?
|
|
33
26
|
# We need to check browser_validations because
|
|
34
27
|
# some browsers are still checking required even
|
|
@@ -74,7 +74,7 @@ module SimpleForm
|
|
|
74
74
|
if SimpleForm.translate_labels && (translated_label = translate_from_namespace(:labels))
|
|
75
75
|
translated_label
|
|
76
76
|
elsif object.class.respond_to?(:human_attribute_name)
|
|
77
|
-
object.class.human_attribute_name(reflection_or_attribute_name.to_s)
|
|
77
|
+
object.class.human_attribute_name(reflection_or_attribute_name.to_s, { base: object })
|
|
78
78
|
else
|
|
79
79
|
attribute_name.to_s.humanize
|
|
80
80
|
end
|
|
@@ -274,7 +274,7 @@ module SimpleForm
|
|
|
274
274
|
options = options.dup
|
|
275
275
|
|
|
276
276
|
options[:error_prefix] ||= if object.class.respond_to?(:human_attribute_name)
|
|
277
|
-
object.class.human_attribute_name(attribute_name.to_s)
|
|
277
|
+
object.class.human_attribute_name(attribute_name.to_s, { base: object })
|
|
278
278
|
else
|
|
279
279
|
attribute_name.to_s.humanize
|
|
280
280
|
end
|
|
@@ -599,7 +599,11 @@ module SimpleForm
|
|
|
599
599
|
|
|
600
600
|
def find_attribute_column(attribute_name)
|
|
601
601
|
if @object.respond_to?(:type_for_attribute) && @object.has_attribute?(attribute_name)
|
|
602
|
-
@object.type_for_attribute(attribute_name.to_s)
|
|
602
|
+
detected_type = @object.type_for_attribute(attribute_name.to_s)
|
|
603
|
+
|
|
604
|
+
# Some attributes like ActiveRecord::Encryption::EncryptedAttribute are detected
|
|
605
|
+
# as different type, in that case we need to use the original type
|
|
606
|
+
detected_type.respond_to?(:cast_type) ? detected_type.cast_type : detected_type
|
|
603
607
|
elsif @object.respond_to?(:column_for_attribute) && @object.has_attribute?(attribute_name)
|
|
604
608
|
@object.column_for_attribute(attribute_name)
|
|
605
609
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module SimpleForm
|
|
3
|
+
module Inputs
|
|
4
|
+
class WeekdayInput < CollectionSelectInput
|
|
5
|
+
enable :placeholder
|
|
6
|
+
|
|
7
|
+
def input(wrapper_options = nil)
|
|
8
|
+
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
|
|
9
|
+
|
|
10
|
+
@builder.weekday_select(attribute_name, input_options, merged_input_options)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
data/lib/simple_form/inputs.rb
CHANGED
data/lib/simple_form/version.rb
CHANGED
data/lib/simple_form.rb
CHANGED
|
@@ -73,11 +73,11 @@ See http://blog.plataformatec.com.br/2019/09/incorrect-access-control-in-simple-
|
|
|
73
73
|
mattr_accessor :error_notification_class
|
|
74
74
|
@@error_notification_class = :error_notification
|
|
75
75
|
|
|
76
|
-
# Series of
|
|
76
|
+
# Series of attempts to detect a default label method for collection.
|
|
77
77
|
mattr_accessor :collection_label_methods
|
|
78
78
|
@@collection_label_methods = %i[to_label name title to_s]
|
|
79
79
|
|
|
80
|
-
# Series of
|
|
80
|
+
# Series of attempts to detect a default value method for collection.
|
|
81
81
|
mattr_accessor :collection_value_methods
|
|
82
82
|
@@collection_value_methods = %i[id to_s]
|
|
83
83
|
|
|
@@ -178,7 +178,7 @@ See http://blog.plataformatec.com.br/2019/09/incorrect-access-control-in-simple-
|
|
|
178
178
|
mattr_accessor :cache_discovery
|
|
179
179
|
@@cache_discovery = defined?(Rails.env) && !Rails.env.development?
|
|
180
180
|
|
|
181
|
-
# Adds a class to each generated button, mostly for
|
|
181
|
+
# Adds a class to each generated button, mostly for compatibility.
|
|
182
182
|
mattr_accessor :button_class
|
|
183
183
|
@@button_class = 'button'
|
|
184
184
|
|
metadata
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simple_form
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- José Valim
|
|
8
|
-
- Carlos
|
|
8
|
+
- Carlos Antonio
|
|
9
9
|
- Rafael França
|
|
10
|
-
autorequire:
|
|
11
10
|
bindir: bin
|
|
12
11
|
cert_chain: []
|
|
13
|
-
date:
|
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
14
13
|
dependencies:
|
|
15
14
|
- !ruby/object:Gem::Dependency
|
|
16
15
|
name: activemodel
|
|
@@ -18,30 +17,58 @@ dependencies:
|
|
|
18
17
|
requirements:
|
|
19
18
|
- - ">="
|
|
20
19
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: '
|
|
20
|
+
version: '7.0'
|
|
22
21
|
type: :runtime
|
|
23
22
|
prerelease: false
|
|
24
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
24
|
requirements:
|
|
26
25
|
- - ">="
|
|
27
26
|
- !ruby/object:Gem::Version
|
|
28
|
-
version: '
|
|
27
|
+
version: '7.0'
|
|
29
28
|
- !ruby/object:Gem::Dependency
|
|
30
29
|
name: actionpack
|
|
31
30
|
requirement: !ruby/object:Gem::Requirement
|
|
32
31
|
requirements:
|
|
33
32
|
- - ">="
|
|
34
33
|
- !ruby/object:Gem::Version
|
|
35
|
-
version: '
|
|
34
|
+
version: '7.0'
|
|
36
35
|
type: :runtime
|
|
37
36
|
prerelease: false
|
|
38
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
39
38
|
requirements:
|
|
40
39
|
- - ">="
|
|
41
40
|
- !ruby/object:Gem::Version
|
|
42
|
-
version: '
|
|
41
|
+
version: '7.0'
|
|
42
|
+
- !ruby/object:Gem::Dependency
|
|
43
|
+
name: country_select
|
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - ">="
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '0'
|
|
49
|
+
type: :development
|
|
50
|
+
prerelease: false
|
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '0'
|
|
56
|
+
- !ruby/object:Gem::Dependency
|
|
57
|
+
name: rake
|
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
|
59
|
+
requirements:
|
|
60
|
+
- - ">="
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: '0'
|
|
63
|
+
type: :development
|
|
64
|
+
prerelease: false
|
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
66
|
+
requirements:
|
|
67
|
+
- - ">="
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '0'
|
|
43
70
|
description: Forms made easy!
|
|
44
|
-
email: heartcombo@
|
|
71
|
+
email: heartcombo.oss@gmail.com
|
|
45
72
|
executables: []
|
|
46
73
|
extensions: []
|
|
47
74
|
extra_rdoc_files: []
|
|
@@ -102,6 +129,7 @@ files:
|
|
|
102
129
|
- lib/simple_form/inputs/rich_text_area_input.rb
|
|
103
130
|
- lib/simple_form/inputs/string_input.rb
|
|
104
131
|
- lib/simple_form/inputs/text_input.rb
|
|
132
|
+
- lib/simple_form/inputs/weekday_input.rb
|
|
105
133
|
- lib/simple_form/map_type.rb
|
|
106
134
|
- lib/simple_form/railtie.rb
|
|
107
135
|
- lib/simple_form/tags.rb
|
|
@@ -122,7 +150,6 @@ metadata:
|
|
|
122
150
|
source_code_uri: https://github.com/heartcombo/simple_form
|
|
123
151
|
bug_tracker_uri: https://github.com/heartcombo/simple_form/issues
|
|
124
152
|
wiki_uri: https://github.com/heartcombo/simple_form/wiki
|
|
125
|
-
post_install_message:
|
|
126
153
|
rdoc_options: []
|
|
127
154
|
require_paths:
|
|
128
155
|
- lib
|
|
@@ -130,15 +157,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
130
157
|
requirements:
|
|
131
158
|
- - ">="
|
|
132
159
|
- !ruby/object:Gem::Version
|
|
133
|
-
version: 2.
|
|
160
|
+
version: 2.7.0
|
|
134
161
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
162
|
requirements:
|
|
136
163
|
- - ">="
|
|
137
164
|
- !ruby/object:Gem::Version
|
|
138
165
|
version: '0'
|
|
139
166
|
requirements: []
|
|
140
|
-
rubygems_version: 3.
|
|
141
|
-
signing_key:
|
|
167
|
+
rubygems_version: 3.6.9
|
|
142
168
|
specification_version: 4
|
|
143
169
|
summary: Forms made easy!
|
|
144
170
|
test_files: []
|