本文介绍了将自定义按钮添加到活动管理表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在这种情况下,是否可以在通过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更多推荐
将自定义按钮添加到活动管理表单
发布评论