method
field_name
v7.1.3.2 -
Show latest stable
- Class:
ActionView::Helpers::FormTagHelper
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 :post, :title, name: field_name(:post, :title, :subtitle) %> <%# => <input type="text" name="post[title][subtitle]"> %> <%= text_field :post, :tag, name: field_name(:post, :tag, multiple: true) %> <%# => <input type="text" name="post[tag][]"> %>