nested_form_fields 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/nested_form_fields.rb +8 -1
- data/lib/nested_form_fields/version.rb +1 -1
- metadata +1 -1
data/lib/nested_form_fields.rb
CHANGED
@@ -67,6 +67,13 @@ module ActionView::Helpers
|
|
67
67
|
|
68
68
|
def nested_model_template name, association_name, options, block
|
69
69
|
for_template = self.options[:for_template]
|
70
|
+
|
71
|
+
# Render the outermost template in a script tag to avoid it from being submited with the form
|
72
|
+
# Render all deeper nested templates as hidden divs as nesting script tags messes up the html.
|
73
|
+
# When nested fields are added with javascript by using a template that contains nested templates,
|
74
|
+
# the outermost nested templates div's are replaced by script tags to prevent those nested templates
|
75
|
+
# fields from form subission.
|
76
|
+
#
|
70
77
|
@template.content_tag( for_template ? :div : :script,
|
71
78
|
type: for_template ? nil : 'text/html',
|
72
79
|
id: template_id(association_name),
|
@@ -99,7 +106,7 @@ module ActionView::Helpers
|
|
99
106
|
|
100
107
|
|
101
108
|
def nested_fields_wrapper association_name
|
102
|
-
@template.content_tag :
|
109
|
+
@template.content_tag :fieldset, class: "nested_fields nested_#{association_path(association_name)}" do
|
103
110
|
yield
|
104
111
|
end
|
105
112
|
end
|