提交 ee0b92ec 编写于 作者: S Santiago Pastorino

fields_for with inline blocks and nested attributes already persisted does not render properly

[#6381 state:committed]
上级 631e23ec
......@@ -549,8 +549,11 @@ def apply_form_for_options!(object_or_array, options) #:nodoc:
# <% end %>
# ...
# <% end %>
def fields_for(record, record_object = nil, options = nil, &block)
capture(instantiate_builder(record, record_object, options, &block), &block)
def fields_for(record, record_object = nil, options = {}, &block)
builder = instantiate_builder(record, record_object, options, &block)
output = capture(builder, &block)
output.concat builder.hidden_field(:id) if output && options[:hidden_field_id] && !builder.emitted_hidden_id?
output
end
# Returns a label tag tailored for labelling an input field for a specified attribute (identified by +method+) on an object
......@@ -1323,14 +1326,8 @@ def fields_for_with_nested_attributes(association_name, args, block)
def fields_for_nested_model(name, object, options, block)
object = convert_to_model(object)
if object.persisted?
@template.fields_for(name, object, options) do |builder|
block.call(builder)
@template.concat builder.hidden_field(:id) unless builder.emitted_hidden_id?
end
else
@template.fields_for(name, object, options, &block)
end
options[:hidden_field_id] = object.persisted?
@template.fields_for(name, object, options, &block)
end
def nested_child_index(name)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册