form_tag 是否与 Simple_form 一起使用? [英] Does form_tag work with Simple_form?
问题描述
我有一个使用 form_tag
的表单,但不确定如何将它与 simple_form gem 一起使用.这是我的表单的外观:
I have a form that is using form_tag
and not sure how to use it with the simple_form gem. This is how my form looks:
<%= form_tag create_multiple_prices_path, :method => :post do %>
<% @prices.each_with_index do |price, index| %>
<%= fields_for "prices[#{index}]", price do |up| %>
<%= render "fields", :f => up %>
<% end %>
<% end %>
<%= submit_tag "Done" %>
<% end %>
能做到吗?form_tag
如何更改以正确使用 simple_form?与 fields_for
一起使用时怎么样?新手可能需要一些帮助.
Can it be done? How would a form_tag
change to use simple_form correctly? What about when using it with fields_for
? A Newbie could use some help.
谢谢.
推荐答案
simple_form 是 form_for
的包装器,而不是 form_tag
.您可以使用 simple_form_for
而不是 form_for
,但是 form_tag
只是创建具有指定内容的 标签,它与简单形式无关.
simple_form is a wrapper around form_for
, not form_tag
. You can use simple_form_for
instead of form_for
, but form_tag
just creates <form>
tags with specified content, it is not relevant to simple form.
这篇关于form_tag 是否与 Simple_form 一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!