简体   繁体   English

Rails button_to用于自定义名称/值提交

[英]Rails button_to for Custom Name / Value Submit

In Rails is it possible to achieve an HTML output like this using button_to ? 在Rails中,可以使用button_to实现这样的HTML输出吗?

<button type="submit" value="1" name="id">Type 1</button>
<button type="submit" value="2" name="id">Type 2</button>

What are the reasons for using button_to over manually entering the HTML in my form? 使用button_to手动在表单中输入HTML的原因是什么?

... ...

EDIT: 编辑:

Perhaps I should rephrase this? 也许我应该改写这个? Seems the better way would be to add some hidden fields to the button_to form. 似乎更好的方法是将一些隐藏字段添加到button_to表单。 It doesn't seem like I can do this. 看来我无法做到这一点。

So what is the correct Rails solution to pass extra hidden fields to a dynamic form generated via a button_to ? 那么,将额外的隐藏字段传递给通过button_to生成的动态表单的正确Rails解决方案是什么? Or should I just build a form manually? 还是我应该手动构建表单?

eg I have: 例如我有:

button_to "Download", items_path(:release_id => release), :remote => true

and I want to pass an extra parameter in the form POST format => "download" 我想以POST format => "download"的形式传递一个额外的参数

似乎我的答案是使用form_tag帮助器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM