-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Templates break when nesting inside a regular Rails fields_for #63
Comments
Looks like you used the wrong builders in the nested forms. I think it should be:
|
Oops, that was a typo from my end. Now the question should be corrected. The problem persists. We're looking into if the |
I haven't tested this case yet. I can look into it as soon as I have some time. Let me know if you find the issue. ;-) |
It works with the following changes: form_for @resource do |f|
f.nested_fields_for :foo do |ff|
ff.fields_for :bar do |fff|
fff.nested_fields_for :baz, for_template: true do |ffff|
# stuff
end
end
end
end That is, we pass along def nested_model_template name, association_name, options, block
for_template = options[:for_template] || self.options[:for_template] Not sure if this is a workable way to solve it? We also couldn't find where |
Actually, if you set form_for @resource do |f|
f.nested_fields_for :foo do |ff|
ff.fields_for :bar, for_template: true do |fff|
fff.nested_fields_for :baz do |ffff|
# stuff
end
end
end
end |
Okay, good, but it is a hack :) for_template is an internal option only. Hm. I'd like to find a better solution. But might be tricky. |
Probably to do this cleanly we will have to patch fields_for to pass down the for_template option from the parent builder... But glad you found a workaround. Although, more correct would probably be:
Because for_template should only be true when the form is rendered as a nested form fields template. |
I'm having some trouble with deeply nested form fields. It works fine when nesting only using
nested_fields_for
but if I add a regularfields_for
in between, the generated<script>
template tag breaks.In this case,
bar
is abelongs_to
relation onfoo
, which means I cannot usenested_fields_for
which expects a relation.The text was updated successfully, but these errors were encountered: