mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
fields_for with inline blocks and nested attributes already persisted does not render properly
[#6381 state:committed]
This commit is contained in:
parent
631e23ec6c
commit
ee0b92ec7a
1 changed files with 7 additions and 10 deletions
|
@ -549,8 +549,11 @@ module ActionView
|
||||||
# <% end %>
|
# <% end %>
|
||||||
# ...
|
# ...
|
||||||
# <% end %>
|
# <% end %>
|
||||||
def fields_for(record, record_object = nil, options = nil, &block)
|
def fields_for(record, record_object = nil, options = {}, &block)
|
||||||
capture(instantiate_builder(record, record_object, options, &block), &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
|
end
|
||||||
|
|
||||||
# Returns a label tag tailored for labelling an input field for a specified attribute (identified by +method+) on an object
|
# Returns a label tag tailored for labelling an input field for a specified attribute (identified by +method+) on an object
|
||||||
|
@ -1323,15 +1326,9 @@ module ActionView
|
||||||
def fields_for_nested_model(name, object, options, block)
|
def fields_for_nested_model(name, object, options, block)
|
||||||
object = convert_to_model(object)
|
object = convert_to_model(object)
|
||||||
|
|
||||||
if object.persisted?
|
options[:hidden_field_id] = 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)
|
@template.fields_for(name, object, options, &block)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def nested_child_index(name)
|
def nested_child_index(name)
|
||||||
@nested_child_index[name] ||= -1
|
@nested_child_index[name] ||= -1
|
||||||
|
|
Loading…
Reference in a new issue