【问题标题】:Add link on edit form for activeadmin在活动管理员的编辑表单上添加链接
【发布时间】:2019-10-11 12:41:21
【问题描述】:

我需要在 ActiveAdmin 的表单中间添加一个链接/按钮。我尝试为 has_multiple 字段添加操作,但它不起作用:

form
 ..

 f.has_many :colors, sortable: :position, sortable_start: 1 do |a|
  a.input :name
  a.action :cancel, :as => :link, :url => "/path"
 end
end

【问题讨论】:

  • 你检查过 [activeadmin.info/5-forms.html#nested-resources] 吗?链接应该做什么?如果你想为 nested_resource 设置一个“删除/销毁”复选框,它应该由 AA 本身覆盖。不要忘记使用accepts_nested_atrributesallow_destroy => true 设置模型并设置permit_params
  • 这是自定义操作。不破坏。

标签: ruby-on-rails-5 activeadmin


【解决方案1】:

也许是这样的?

f.has_many :colors, sortable: :position, sortable_start: 1 do |a|
  a.input :name
  div do
    link_to("My custom action", custom_path(:some_parameter => a.object.id), :method => :post)
  end
end

【讨论】:

    最近更新 更多