【发布时间】:2016-11-26 01:47:25
【问题描述】:
我目前正在使用 activeadmin 创建嵌套表单。我可以单击添加嵌套资源按钮,该按钮将显示相应嵌套资源的输入。但是,我希望默认显示输入,而不必单击添加资源按钮(即,一旦加载表单,就应该显示输入)。 我已经根据 ActiveAdmin 文档重新检查了我的代码,还检查了各种 stackoverflow 帖子,但没有取得太大进展。
Picture of how the form current looks like
我的代码在admin/project.rb中如下:
form title: 'Create a New Project' do |f|
f.inputs 'Basic Information' do
f.input :category
f.input :name
f.input :location
f.input :size, sortable: :size do |project|
"#{project.size}m2"
end
f.input :published?
f.has_many :project_main_image, heading: 'Project main image', allow_destroy: true, new_record: false do |a|
a.input :photo, hint: image_tag(a.object.photo.thumb.url, class: 'active-admin-thumbnail')
a.input :orientation
end
f.has_many :project_descriptions, allow_destroy: true do |a|
a.input :contents, as: :ckeditor, input_html: { ckeditor: { toolbar: 'Full' } }
end
f.has_many :project_gallery_images, allow_destroy: true do |a|
a.input :photo, hint: image_tag(a.object.photo.thumb.url, class: 'active-admin-thumbnail')
a.input :orientation
a.input :row_order
end
f.actions
end
end
任何反馈或建议。如果您需要更多信息,请告诉我。
【问题讨论】:
标签: ruby-on-rails forms activeadmin