method

field_name

field_name(method, *methods, multiple: false, index: @options[:index])
public

Generate an HTML name attribute value for the given name and field combination

Return the value generated by the FormBuilder for the given attribute name.

<%= form_for @post do |f| %>
  <%= f.text_field :title, name: f.field_name(:title, :subtitle) %>
  <%# => <input type="text" name="post[title][subtitle]"> %>
<% end %>

<%= form_for @post do |f| %>
  <%= f.text_field :tag, name: f.field_name(:tag, multiple: true) %>
  <%# => <input type="text" name="post[tag][]"> %>
<% end %>