0

I looked at this question and was able to get set up a has_many form properly.

Here's where I'm at:

f.has_many :related_contents do |rc|
  rc.inputs "first configuration" do
    #...
  end
end
f.has_many :related_contents do |rc|
  rc.inputs "second configuration do
    #...
  end
end

so I want to have different configurations of fields. What I can't figure out is how to set the <h3> that activeadmin generates and sets as the title for the nested fields. I thought something like

f.has_many :related_contents, :title => "first set" do |rc|

would work, but It does not. Does anybody know what I need to do to get this working right?

I assume that changing the <h3> will also change the button that gets generated to add. Is there another option I need to set for that as well?

Community
  • 1
  • 1
pizza247
  • 3,869
  • 7
  • 33
  • 47
  • I fixed it with javascript... but that seems like a hack. There should be a way to do this with activeadmin. – pizza247 Jun 20 '12 at 21:50

3 Answers3

2

Add a :heading option to the f.has_many method

f.has_many :related_contents, :heading => "first set" do |rc|
  #...
end

To remove the heading altogether, set it to false or nil

alkalinecoffee
  • 1,003
  • 8
  • 20
  • This seems to be [a new addition](https://github.com/gregbell/active_admin/blob/master/CHANGELOG.md) as of ActiveAdmin 0.6.1! Great tip! – Steve Grossi Sep 26 '13 at 20:30
0

you need to follow the next order, i mean, you need to set on first line the "inputs" and then the "has_many" block, I hope this is what you are looking, regards!

form do |f|
  f.inputs "details #1" do
    f.input :title, :label => "Title"
    f.input :description, :label => "Description"
    f.input :image, :as => :file, :required => false, :label=>'Image'  

  end

  f.inputs "details #2" do
   f.has_many :subdetails do |a|
       a.input :description, :label => "Description"
       a.input :image, :as => :file, :required => false, :label=>'Image'
   end  
 end

Ok, after have some problems with the title of has_many I could figure out how is the correct way for do it and i think is more cleaner and fancy...

form do |f|
    f.inputs "Post" do

      f.input :title
      f.input :description

    end

    f.inputs "Comments" do
     f.has_many :comments do |a|

        a.input :title
        a.input :description

      end  
    end

    f.buttons
end
rome3ro
  • 131
  • 1
  • 6
  • this creates another bar with a name, and appears redundant visually on the page. Not really what I was looking for. – pizza247 Jul 05 '12 at 16:24
0
$('h3:contains("Related Contents")').hide().first().show();

Not perfect, but it definitely looks better.

pizza247
  • 3,869
  • 7
  • 33
  • 47