【问题标题】:is there any way to customize the buttons generated by activeadmin formbuilder有什么方法可以自定义由activeadmin formbuilder生成的按钮
【发布时间】:2021-05-10 08:42:41
【问题描述】:
form do |f|
    f.inputs "Mission" do
      f.input :level
      f.input :points
      f.input :title
      f.input :description
    end

    f.has_many :requirements do |r|
      r.input :kind, as: :select, collection: %w(text video image)
      r.input :count
      r.input :description, as: :text
    end

    f.actions
  end

这实际上是在表单底部生成一个“添加新需求”按钮。现在我想自定义那个按钮,比如想要添加自定义 id 或者想要更改名称,我该怎么做

【问题讨论】:

    标签: ruby-on-rails activeadmin formtastic


    【解决方案1】:

    ActiveAdmin 的表单在后台使用 Formtasic,并且操作支持passing a block,您可以在其中呈现几乎您想要的内容。例如:

    <%= f.actions do %>
      <%= f.action :submit, label: 'My text', id: 'some-id' %>
    <% end %>
    

    【讨论】:

    • 我认为这将添加新按钮 bt 我想控制现有按钮“添加新要求”
    • @Abubakkarsiddique 您无法处理现有按钮,但您可以覆盖它,正如我在回答中向您展示的那样。我建议阅读我链接到的文档。
    猜你喜欢
    • 2011-06-12
    • 1970-01-01
    • 2019-08-04
    • 1970-01-01
    • 1970-01-01
    • 2019-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多