justinfrench/formtastic — Issue #771: Unable to supply `%i` in :label option
Author: mhuggins
Created: 2011-12-30 04:34:24+00:00
State: open

I have a `has_many` relationship that is being included when creating new objects. I would like to include the index of the `has_many` object within the `:label` attribute of the input, similar to how `%i` can be used to specify the index of the `:name` attribute in an `inputs` loop.

In other words, instead of doing this:

<%= f.inputs :for => :options, :name => 'Answer Choice %i' do |o| -%>
<%= o.input :body %>
<% end -%>

I would like to do this:

<%= f.inputs :for => :options do |o| -%>
<%= o.input :body, :label => "Answer Choice %i" %>
<% end -%>

Is there already a way of doing this? If so, I couldn't find it in the documentation or scanning through the code.