mixbo
mixbo

Reputation: 35

in activeadmin form input not working in array?

in active_admin: some code not work like this:

form do |f|
 f.inputs "title" do
   %w(AreaGroupId DescriptionFlags Dispel Mechanic modalNextSpell).each do |ele|
     f.input ele
   end
  end
end

when i write other format like this:

form do |f|
  f.inputs "title" do
     f.input AreaGroupId
     f.input DescriptionFlags
     f.input Dispel
     f.input Mechanic
     f.input modalNextSpell
  end
end

so the can run

why ? something wrong ?

Upvotes: 0

Views: 873

Answers (1)

Zequez
Zequez

Reputation: 3499

That's because how Formtastic works, the block given to f.inputs has to return the last input. If you want a quick fix, try the following:

form do |f|
 f.inputs "title" do
   %w(AreaGroupId DescriptionFlags Dispel Mechanic modalNextSpell).map do |ele|
     f.input ele
   end.last
  end
end

Upvotes: 1

Related Questions