method

field_name

Importance_1
v7.1.3.4 - Show latest stable - 0 notes - 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][]"> %>
Show source
Register or log in to add new notes.