so the :child_index => "new_#{association}" is ignored?
same code is working well with interfaces:
<div class="interfaces_fields_template form_template" style="display:
none;">
<input id="host_interfaces_attributes_new_interfaces__destroy"
class="destroyFlag" type="hidden"
name="host[interfaces_attributes][new_interfaces][_destroy]" value="0">
</div>
Playing around with fields_for and child_index, it seems i'm missing an
accepts_nested_attributes_for :volumes
somehow.
But where is the correct place to put this?
···
Am 21.02.2017 um 18:55 schrieb Martin Frank:
> I'm working on my own compute_resource but I got stuck creating more
> than one volume.
>
> To drag down the problem i looked into the foreman code.
>
> In app/helpers/layout_helper.rb is the function new_child_fields_template
>
> here i added a f.hidden_field
>
> content_tag(:div, :class => "#{association}_fields_template
> form_template", :style => "display: none;") do
> form_builder.fields_for(association, options[:object],
> :child_index => "new_#{association}") do |f|
> f.hidden_field(:_destroy, :class => :destroyFlag, :value => 0)
> #render(:partial => options[:partial], :layout =>
> options[:layout],
> # :locals => { options[:form_builder_local] => f
> }.merge(options[:form_builder_attrs]))
> end
> end
>
> the generated html code looks like this:
>
>
> Still trying to figure this out.
>
> Playing around with fields_for and child_index, it seems i'm missing an
> accepts_nested_attributes_for :volumes
> somehow.
>
> But where is the correct place to put this?
In the model, I would think grep'ing for that recursively would yield an
example
···
On Sat, 25 Feb 2017 at 17:11, Martin Frank wrote:
Am 21.02.2017 um 18:55 schrieb Martin Frank:
I’m working on my own compute_resource but I got stuck creating more
than one volume.
To drag down the problem i looked into the foreman code.
In app/helpers/layout_helper.rb is the function new_child_fields_template
here i added a f.hidden_field
content_tag(:div, :class => “#{association}fields_template
form_template", :style => “display: none;”) do
form_builder.fields_for(association, options[:object],
:child_index => "new#{association}”) do |f|
f.hidden_field(:_destroy, :class => :destroyFlag, :value => 0) #render(:partial => options[:partial], :layout =>
options[:layout],
# :locals => { options[:form_builder_local] => f
}.merge(options[:form_builder_attrs]))
end
end
the generated html code looks like this:
but i think it should look like this:
so the :child_index => “new_#{association}” is ignored?