title: Add field_with_error to dynamically named form field
body: <p>I want to create a form for edit a record of Item model <strong>WITHOUT showing id of Item</strong> on html.<br />
  To identify Item record, I use <strong>id_sub</strong> column.<br />
  (<strong>id_sub</strong> is 10 characters string.)</p>
  <h3>models/item.rb</h3>
  <pre><code>def item
    # ---------- columns ----------
    # id     : integer, primary key
    # id_sub : string
    # name   : string
  end
  </code></pre>
  <p>Because I don't want to show <strong>Item's id</strong>, I use <strong>id_sub</strong> for fields and parameters.</p>
  <p>This works fine.<br />
  However, when it has errors, <strong>field_with_error</strong> doesn't be added to form.</p>
  <p>It is because Rails can't find field dynamically named, I think.<br />
  Are there ways to have Rails to find dynamically named field?<br />
  Or does only way is using JavaScript for it?</p>
  <h3>controllers/items_controller.rb</h3>
  <pre><code>def update_all
    @errors = []
    @items = params[:item].map do |id_sub, item_params|
      item = Item.find_by(id_sub: id_sub)
      if item &amp;&amp; !item.update(name: item_params[:name])
        @errors &lt;&lt; item.errors
      end
      item
    end
  
    if @errors.blank?
      redirect_to :edit_all_items
    else
      render :edit_all
    end
  end
  </code></pre>
  <h3>views/items/edit_all.html.haml</h3>
  <pre><code>= form_tag update_all_items_path, method: :patch do
    - @items.each do |item|
        = fields_for 'items[]', item do |f|
  
          -# --- Dynamically named field below. ---
          = text_field_tag &quot;items[#{item.id_sub}][name]&quot;
          = submit_tag
  </code></pre>
  <p>Any help is going to be appreciated. :)</p>