method

field_name

field_name(object_name, method_name, *method_names, multiple: false, index: nil)
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.

<%= text_field_tag :post, :title, name: field_name(:post, :title, :subtitle) %>
<%# => <input type="text" name="post[title][subtitle]">

<%= text_field_tag :post, :tag, name: field_name(:post, :tag, multiple: true) %>
<%# => <input type="text" name="post[tag][]">