如何将目标添加到 Rails 表单助手?

Arc*_*nic 0 ruby-on-rails-3.2

我正在使用form_for帮助程序并希望将其提交到 iframe。

<%= form_for(section, :target => 'new_section_frame') do |f| %>
  ...
<% end %>
Run Code Online (Sandbox Code Playgroud)

然后我应该能够调用$('form').submit()并将表单提交到 iframe。除非目标不存在于输出 html 中,否则它会起作用。Rails关于表单助手的指南没有这个特定的示例。

Arc*_*nic 5

与 html 相关的帮助器选项form_for必须位于 html 键中。就像这样:

<%= form_for(section, :html => {:target=>'new_section_frame'}) do |f| %>
  ...
<% end %>
Run Code Online (Sandbox Code Playgroud)