nested_form_fields 0.2.0 → 0.3.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.
- data/lib/nested_form_fields.rb +5 -4
- data/lib/nested_form_fields/version.rb +1 -1
- metadata +4 -4
data/lib/nested_form_fields.rb
CHANGED
@@ -16,6 +16,7 @@ module ActionView::Helpers
|
|
16
16
|
fields_options[:builder] ||= options[:builder]
|
17
17
|
fields_options[:parent_builder] = self
|
18
18
|
fields_options[:wrapper_tag] ||= :fieldset
|
19
|
+
fields_options[:legend] ||= nil
|
19
20
|
fields_options[:namespace] = fields_options[:parent_builder].options[:namespace]
|
20
21
|
|
21
22
|
return fields_for_has_many_association_with_template(record_name, record_object, fields_options, block)
|
@@ -49,7 +50,7 @@ module ActionView::Helpers
|
|
49
50
|
|
50
51
|
output = ActiveSupport::SafeBuffer.new
|
51
52
|
association.each do |child|
|
52
|
-
output << nested_fields_wrapper(association_name, options[:wrapper_tag]) do
|
53
|
+
output << nested_fields_wrapper(association_name, options[:wrapper_tag], options[:legend]) do
|
53
54
|
fields_for_nested_model("#{name}[#{options[:child_index] || nested_child_index(name)}]", child, options, block)
|
54
55
|
end
|
55
56
|
end
|
@@ -73,7 +74,7 @@ module ActionView::Helpers
|
|
73
74
|
id: template_id(association_name),
|
74
75
|
class: for_template ? 'form_template' : nil,
|
75
76
|
style: for_template ? 'display:none' : nil ) do
|
76
|
-
nested_fields_wrapper(association_name, options[:wrapper_tag]) do
|
77
|
+
nested_fields_wrapper(association_name, options[:wrapper_tag], options[:legend]) do
|
77
78
|
fields_for_nested_model("#{name}[#{index_placeholder(association_name)}]",
|
78
79
|
association_name.to_s.classify.constantize.new,
|
79
80
|
options.merge(for_template: true), block)
|
@@ -99,9 +100,9 @@ module ActionView::Helpers
|
|
99
100
|
end
|
100
101
|
|
101
102
|
|
102
|
-
def nested_fields_wrapper association_name, wrapper_element_type
|
103
|
+
def nested_fields_wrapper association_name, wrapper_element_type, legend
|
103
104
|
@template.content_tag wrapper_element_type, class: "nested_fields nested_#{association_path(association_name)}" do
|
104
|
-
yield
|
105
|
+
(wrapper_element_type==:fieldset && !legend.nil?)? ( @template.content_tag(:legend, legend, class: "nested_fields") + yield ) : yield
|
105
106
|
end
|
106
107
|
end
|
107
108
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nested_form_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -253,7 +253,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
253
253
|
version: '0'
|
254
254
|
segments:
|
255
255
|
- 0
|
256
|
-
hash:
|
256
|
+
hash: -2204789679790025612
|
257
257
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
258
258
|
none: false
|
259
259
|
requirements:
|
@@ -262,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
262
262
|
version: '0'
|
263
263
|
segments:
|
264
264
|
- 0
|
265
|
-
hash:
|
265
|
+
hash: -2204789679790025612
|
266
266
|
requirements: []
|
267
267
|
rubyforge_project:
|
268
268
|
rubygems_version: 1.8.25
|