On Sat, 25 Feb 2017 at 17:11, Martin Frank <[email protected]> wrote:
> 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 :-)
>
>
>
> 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:
> >
> > <div class="volumes_fields_template form_template" style="display:
> > none;">
> > <input id="host_compute_attributes_volumes__destroy"
> > class="destroyFlag" type="hidden"
> > name="host[compute_attributes][volumes][_destroy]" value="0">
> > </div>
> >
> > but i think it should look like this:
> >
> > <div class="volumes_fields_template form_template" style="display:
> > none;">
> > <input id="host_compute_attributes_new_volumes__destroy"
> > class="destroyFlag" type="hidden"
> > name="host[compute_attributes][new_volumes][_destroy]" value="0">
> > </div>
> >
> > 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>
> >
> > any ideas how to solve this?
> >
> >
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "foreman-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"foreman-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.