active_dry_form 1.3.0 → 1.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/Gemfile.lock +2 -1
- data/lib/active_dry_form/base_form.rb +8 -0
- data/lib/active_dry_form/builder.rb +2 -6
- data/lib/active_dry_form/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4bd09fb7a62c1ed888ddb3abc634ec2b510e9a3be286e3313aa6e6fc58ebea3
|
4
|
+
data.tar.gz: b7a8c47ed543b855ebf8e5baa98206a923adbc54a605d84a836aecdaee5f12c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 011c0a880ae29f2d4084817552d0cc068c769c1e6cbcb3e9691688a65b67cccaca5d48b250249f1f3e7f0618308c23c33ee78209fbcf42db94023f650b7825ad
|
7
|
+
data.tar.gz: 14e4ccba512e7aa7867b1537f4ba136d9b108519ae3fb95472b6237d77b075762a35ce4caf96ec1df583855125a01fba2b620e302429da0dd80c55f888285c6e
|
data/Gemfile.lock
CHANGED
@@ -27,7 +27,7 @@ GIT
|
|
27
27
|
PATH
|
28
28
|
remote: .
|
29
29
|
specs:
|
30
|
-
active_dry_form (1.
|
30
|
+
active_dry_form (1.4.0)
|
31
31
|
actionpack
|
32
32
|
activerecord
|
33
33
|
dry-configurable
|
@@ -198,6 +198,7 @@ GEM
|
|
198
198
|
|
199
199
|
PLATFORMS
|
200
200
|
arm64-darwin-21
|
201
|
+
arm64-darwin-24
|
201
202
|
x86_64-linux
|
202
203
|
|
203
204
|
DEPENDENCIES
|
@@ -48,6 +48,10 @@ module ActiveDryForm
|
|
48
48
|
attrs.each do |attr, v|
|
49
49
|
next if !ActiveDryForm.config.strict_param_keys && !respond_to?(:"#{attr}=")
|
50
50
|
|
51
|
+
# Params for nested forms comes as a hash from frontend, convert them to array
|
52
|
+
# { '0' => { url: 'https://omniplatform.ru' }, '1' => { url: 'https://google.com' } } => [{ ... }, { ... }]
|
53
|
+
v = v.values if v.is_a?(Hash) && self.class::NESTED_FORM_ARRAYS.include?(attr.to_sym)
|
54
|
+
|
51
55
|
public_send(:"#{attr}=", v)
|
52
56
|
end
|
53
57
|
end
|
@@ -143,6 +147,7 @@ module ActiveDryForm
|
|
143
147
|
|
144
148
|
def self.define_methods
|
145
149
|
const_set :NESTED_FORM_KEYS, []
|
150
|
+
const_set :NESTED_FORM_ARRAYS, Set.new
|
146
151
|
|
147
152
|
self::FIELDS_INFO[:properties].each do |key, value|
|
148
153
|
define_method :"#{key}=" do |v|
|
@@ -168,6 +173,9 @@ module ActiveDryForm
|
|
168
173
|
namespace: key,
|
169
174
|
is_array: value[:type] == 'array',
|
170
175
|
}
|
176
|
+
if value[:type] == 'array'
|
177
|
+
self::NESTED_FORM_ARRAYS << key.to_sym
|
178
|
+
end
|
171
179
|
nested_key = key
|
172
180
|
end
|
173
181
|
|
@@ -81,13 +81,9 @@ module ActiveDryForm
|
|
81
81
|
if association.is_a?(BaseForm)
|
82
82
|
fields_for_nested_model("#{@object_name}[#{association_name}]", association, fields_options, block)
|
83
83
|
elsif association.respond_to?(:to_ary)
|
84
|
-
|
85
|
-
|
86
|
-
Array.wrap(association).each do |child|
|
87
|
-
output << fields_for_nested_model("#{@object_name}[#{association_name}][]", child, fields_options, block)
|
88
|
-
.gsub(field_name_regexp, "#{@object_name}[#{association_name}][]").html_safe
|
84
|
+
Array.wrap(association).each_with_index.reduce(ActiveSupport::SafeBuffer.new) do |output, (child, i)|
|
85
|
+
output << fields_for_nested_model("#{@object_name}[#{association_name}][#{i}]", child, fields_options, block)
|
89
86
|
end
|
90
|
-
output
|
91
87
|
end
|
92
88
|
end
|
93
89
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_dry_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ermolaev Andrey
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|