Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helpers don't filter the options hash v2.0.0.rc #466

Closed
23inhouse opened this issue Feb 22, 2012 · 3 comments
Closed

Helpers don't filter the options hash v2.0.0.rc #466

23inhouse opened this issue Feb 22, 2012 · 3 comments

Comments

@23inhouse
Copy link

The input method only adds real attributes when creating the html output.

For example

   <%= f.input :name, {:label => 'my label'} %>

Will strip the label from the hash and only show the relevant attributes

   <input id="blog_name" class="numeric string optional" type="text" size="50" name="blog[name]">

Here is the bug

The other helper methods label, hint and full_errors don't clean up the options hash and just pass everything through.

For example

   <%= f.label :name, {:label => 'my label', :hint => 'my hint'} %>
   <%= f.hint :name, {:label => 'my label', :hint => 'my hint'} %>

Will NOT clean up the options hash and then adds lots of extra stuff to the html output

   <label class="string required label" hint="my hint." for="blog_name">my label</label>
   <div min_max="false">my hint</div>
@carlosantoniodasilva
Copy link
Member

Yeah, this is the API for label, hint, and error helpers: everything you give as extra options are going to end up as html attributes, except for a few given keys on each helper. For instance, the hint helper only uses hint_tag and hint from options, everything else is going straight to html options. Same for label and error.

Anyway, I see now that only label is not handling this correctly, I'm gonna fix it. Besides that, SimpleForm cannot guess what is html attribute, it only knows what is internal use and cleans up such options.

Thanks for reporting.

@carlosantoniodasilva
Copy link
Member

Please give it a try bundling from master branch. Thanks.

@23inhouse
Copy link
Author

Yes, that is cleaner. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants