method

field_name

Importance_1
v7.1.3.4 - Show latest stable - 0 notes - Class: ActionView::Helpers::FormBuilder
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 %>
Show source
Register or log in to add new notes.