Reputation: 1428
<%= text_field :foo, :bar %>
will generate
<input id="foo_bar" name="foo[bar]" type="text">
But what I actually want is
<input id="form_foo_bar" name="form[foo][bar]" type="text">
How can I achieve this?
Upvotes: 0
Views: 99
Reputation: 1089
You can do the same with Rails form helpers:
<%= form_for :form do |form| %>
<%= form.fields_for(:foo) do |foo| %>
<%= foo.text_field :bar %>
<% end %>
<% end %>
Upvotes: 1
Reputation: 8065
You can do,
<%= text_field :foo, :bar, :name => "form[foo][bar]" %>
not tried, but should work,
<%= text_field "", "form[foo][bar]" %>
Upvotes: 2