activeadmin: broken has_many form
Hello)
Recently, I used has_many form and encountered with problem: how can I distinguish has_many objects during editing?
the simple ways were to use labeled inputs block, like:
ActiveAdmin.register Pricelist do
permit_params :name, :description, prices_attributes: [:amount]
form do |f|
# ......
f.has_many :prices, heading: false, allow_destroy: false, new_record: false do |price|
price.inputs "#{price.object.try!(:city).try!(:name)}" do
price.input :amount
end
end
# ....
end
or panels:
form do |f|
# ......
f.has_many :prices, heading: false, allow_destroy: false, new_record: false do |price|
panel "#{price.object.try!(:city).try!(:name)}" do
price.input :amount
end
end
# ....
end
but i found that every time form was broken the best temporary solution was wrapping has_many records in main form inputs block:
form do |f|
# ......
f.has_many :prices, heading: false, allow_destroy: false, new_record: false do |price|
price.inputs "#{price.object.try!(:city).try!(:name)}" do
f.input :amount
end
end
# ....
end
it still was broken but looks not so bad (except empty space in form end that get bigger cause there are hidden id inputs)
I create simple test project) and add branch that recreates this problem branch: broken_has_many_form
Can someone help me to solve this problem?)
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 2
- Comments: 18 (15 by maintainers)
@timoschilling , @senid231 . There is workaround for this we can use
concat
method and passArbre::Context
therelooks like it works like deprecated
form_buffers
@Fivell 👍
We can build a arbre method on the FormBuilder to make a shortcut