def has_many(association, association_objects = nil, allow_create:true, &block)

      new_object = self.object.send(association).klass.new

      view_template = self.fields_for(association, new_object, child_index:new_object.object_id) do |builder|
        yield(builder)
      end

      existing_fields = self.fields_for(association, association_objects) do |builder|
        yield(builder)
      end

      render(partial:"admin/shared/forms/has_many", locals: {
        association: association,
        button_label: association.to_s.humanize.singularize.titleize,
        new_object: new_object,
        existing_fields: existing_fields,
        allow_create: allow_create,
        f: self,
        data: {
          template: view_template.tr("\n"," "),
          id: new_object.object_id,
        }
      })

    end
def has_many(association, association_objects = nil, allow_create:true, &block)

      new_object = self.object.send(association).klass.new

      view_template = self.fields_for(association, new_object, child_index:new_object.object_id) do |builder|
        yield(builder)
      end

      existing_fields = self.fields_for(association, association_objects) do |builder|
        yield(builder)
      end

      render(partial:"admin/shared/forms/has_many", locals: {
        association: association,
        button_label: association.to_s.humanize.singularize.titleize,
        new_object: new_object,
        existing_fields: existing_fields,
        allow_create: allow_create,
        f: self,
        data: {
          template: view_template.tr("\n"," "),
          id: new_object.object_id,
        }
      })

    end
Opens an ERB block for UI to manage a `has_many` + `accepts_nested_attributes_for`
 association in the current form. The block will look similar to this:

    <%= f.has_many :footnotes do |ff| %>
      <%= ff.has_many_header allow_destroy:true %>
      <% # Your nested model fields for footnote here %>
    <% end %>

 You must use `f.has_many_header` inside the block to create headers.

 If you need to pass an ordered collection or otherwise not allow automatically
 determining the association objects from the `association` symbol you can
 pass the collection manually as `association_objects`.

 If `allow_create` is `false` then the button to append a new model
 instance will be disabled. The default is `true`.