Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

%1 Only works in name attribute not class/id/etc? #790

Closed
ryanisinallofus opened this Issue · 6 comments

3 participants

@ryanisinallofus

<%= semantic_form_for @post do |f| %>
<%= f.inputs %>
<%= f.inputs :class => 'Category #%i', :for => :categories %>
<%= f.actions %>
<% end %>

That isn't supposed work?

@justinfrench
Owner

I don't think that was ever a feature. What's your use case?

@ryanisinallofus

It's common to give the listed element unique IDs for javascript manipulation.

Formtastic uses fieldsets inside a wrapper li.input for nested records:

<li class="inputs">
  <fieldset>...</fieldset>
  <fieldset>...</fieldset>
  <fieldset>...</fieldset>
</li>

I can't add unique classes to those fieldsets so I can't do much with them in javascript unless I go in and search for a unique id then back out and grab the fieldset that way. Not super efficient.

= f.inputs :class=>"ticket_type type_%i", :name => 'Category_%i', :for => :ticket_types do |tt|

It would be cool if you could do something like the above or below:

= f.inputs :wrapper_html=>{:class=>"ticket_type type_%i", :for => :ticket_types do |tt|

The output might be:

<li class="inputs">
  <fieldset class="ticket_type type_1">...</fieldset>
  <fieldset class="ticket_type type_2">...</fieldset>
  <fieldset class="ticket_type type_3">...</fieldset>
</li>

Or if both options worked:

= f.inputs :class="ticket_type type_%i", :wrapper_html=>{:class=>"ticket_types", :for => :ticket_types do |tt|
<li class="inputs ticket_types">
  <fieldset class="ticket_type type_1">...</fieldset>
  <fieldset class="ticket_type type_2">...</fieldset>
  <fieldset class="ticket_type type_3">...</fieldset>
</li>

Something like that anyway.

Thanks for your response,
Ryan

@justinfrench
Owner

Wondering if there shouldn't just be a unique id on each field set, rather than you having to do this. Either way, I'd accept a patch if you're interested. Unique classes seems a bit, errr, strange, but ids make sense.

@ryanisinallofus

I got around it by using some longer JQuery selectors but I think this would be an awesome feature. Got the OK to work on it at work next time I need it though!

@mhuggins

@ryanisinallofus - Looks like this is a duplicate of #771. I submitted pull request #798, which provides a solution for accessing the current nested attribute index, assuming it is pulled in. :)

@justinfrench

@mhuggins agree, your patch solves this great, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.