将自定义按钮添加到活动管理表单

编程入门 行业动态 更新时间:2024-10-11 23:24:01
本文介绍了将自定义按钮添加到活动管理表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在这种情况下,是否可以在通过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

更多推荐

将自定义按钮添加到活动管理表单

本文发布于:2023-11-28 17:39:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643342.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   表单   按钮

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!