将自定义按钮添加到活动管理表单 [英] Add custom button to active admin form

查看:101
本文介绍了将自定义按钮添加到活动管理表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这种情况下,是否可以在通过f.actions生成的提交和取消按钮旁边添加自定义按钮

Is it at all possible to add a custom button along side the submit and cancel button that is generated with f.actions in this case

文档状态

form do |f|
  f.semantic_errors # shows errors on :base
  f.inputs          # builds an input field for every attribute
  f.actions         # adds the 'Submit' and 'Cancel' buttons
link_to 'Preview', preview_my_admin_panel_posts_path(@post)
end

如何在此处添加内容?

更新

所以我有自己的自定义按钮,现在可以与此

So i have got my custom button to show now with this

inputs 'Submit' do
  f.actions do
    f.action :submit
    f.action :cancel
    f.action :reset
    li do
      link_to 'Preview', preview_my_admin_panel_posts_path()
    end
  end

现在我似乎无法抓住表单对象并传递参数以进行发布,标题评论

Now I cant seem to grab the form object and pass through the params for post, title and comments

谢谢

推荐答案

是,有可能。

定义一个 action_item

action_item only: %i(new edit) do
  link_to 'Preview', preview_my_admin_panel_posts_path(@post)
end

好,我认为您可以执行以下操作:

Ok, I think you could do the following:

form do |f|
  f.semantic_errors
  f.inputs
  f.actions do
    f.submit, as: :button, label: 'Optional custom label'
    f.cancel, as: :link # I think could converted to button as submit
    link_to 'Preview', preview_my_admin_panel_posts_path(@post)
  end
end

这篇关于将自定义按钮添加到活动管理表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆