roda-component 0.1.21 → 0.1.22
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/lib/roda/component/form.rb +25 -3
- data/lib/roda/component/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2762210c34d25092f116906d5f179868ec7a015a
|
4
|
+
data.tar.gz: 90bfc66cfc6a1144f5c6deeeedfa19461efb7a6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 438a6485163a5065b03ebf8e4438f362b4b73abfeda6652db9ddfbca3cdf2c2072ab0d58adf2762edcc4cd252fc1af3816307dc673fa61425c0cac0f6234b0ed
|
7
|
+
data.tar.gz: 7fc115845baaa1abfbd43458722b0160d885cb552e7153f290be24872a5c3a22ada9fc2428d9a7e9e767bac244371c41f34ab74ee9701763741554330691e58e
|
data/lib/roda/component/form.rb
CHANGED
@@ -125,6 +125,28 @@ class Roda
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
+
def model_attributes data = attributes
|
129
|
+
hash = {}
|
130
|
+
|
131
|
+
data.each do |k, v|
|
132
|
+
if klass = _form[k.to_s.to_sym]
|
133
|
+
data = data[k]
|
134
|
+
|
135
|
+
f = klass.new data
|
136
|
+
k = "#{k}_attributes"
|
137
|
+
data = f.attributes
|
138
|
+
|
139
|
+
hash[k] = model_attributes data
|
140
|
+
elsif v.is_a? Hash
|
141
|
+
hash[k] = model_attributes data[k]
|
142
|
+
else
|
143
|
+
hash[k] = v
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
hash
|
148
|
+
end
|
149
|
+
|
128
150
|
def slice(*keys)
|
129
151
|
Hash.new.tap do |atts|
|
130
152
|
keys.each do |att|
|
@@ -134,6 +156,7 @@ class Roda
|
|
134
156
|
end
|
135
157
|
|
136
158
|
def display_errors options = {}
|
159
|
+
dom = options.delete(:dom) || _dom
|
137
160
|
d_errors = errors
|
138
161
|
|
139
162
|
if override_errors = options[:override_errors]
|
@@ -164,11 +187,10 @@ class Roda
|
|
164
187
|
i != 0 ? "[#{field}]" : field
|
165
188
|
end.join
|
166
189
|
|
167
|
-
field_error_dom = options.
|
168
|
-
field_error_dom = DOM.new('<span class="field-error"><span>') unless field_error_dom
|
190
|
+
field_error_dom = DOM.new(`#{options[:tmpl].dom}[0].outerHTML` || '<span class="field-error"><span>')
|
169
191
|
field_error_dom.html _error_name(key, error)
|
170
192
|
|
171
|
-
field =
|
193
|
+
field = dom.find("[name='#{name}']")
|
172
194
|
field.before field_error_dom.dom
|
173
195
|
end
|
174
196
|
end
|