in activeadmin form when I do:
form(:html => { :multipart => true }) do |f|
f.inputs
end
it shows all the fields nicely, and when it comes to belongs_to field it shows them as a collection but I want to replace this collection with a template of my belongs_to field.
Now if I want to use custom belongs_to field I can’t use the power of f.inputs because it will cause repetition. So what can we do now?
Well, currently using this as a solution:
at my “helper/active_admin_helper”:
def form_inputs_for(m)
columns=m.columns.map{|c| c.name}
columns=columns.select{|s| !(s.end_with?"_id" or s.end_with?"_at" or s=="id") }
columns.each do |a|
input a
end
end
and at form:
ActiveAdmin.register ModelClass do
require "helper/active_admin_helper"
form(:html => { :multipart => true }) do |f|
f.inputs do
render "admin/product", f:f
form_inputs_for(ModelClass)
end
end
end
Let me know if you have better solution, in fact I am still looking for one…