plataformatec/simple_form — Issue #467: Helpers are clobbering the (.*)_html options hash in v2.0.0.rc
Author: 23inhouse
Created: 2012-02-22 12:57:09+00:00
State: open

The `:hint_html` and `:label_html` options are being overridden. This erb example results in the html below. It is missing the bar classes and has a lot of extra attributes instead.

```erb

<%= simple_form_for @blog do |form| %>
<%= render :custom_field,
:locals => { :form => form, :options => {
:input => 'foo',
:input_html => {:class => 'bar'},
:hint => 'foo',
:hint_tag => 'p',
:hint_html => {:class => 'bar'},
:label => 'foo',
:label_html => {:class => 'bar'}
}} %>
<% end %>
```

```erb

<%= form.label :name, options %>
<%= form.input :name, options %>
<%= form.hint :name, options %>
<%= form.full_error :name, options %>
```

```html

foo

{:class=>[:string, :optional, [:string, :optional, [:string, :optional, "bar"]]], :size=>50}, :error=>"foo", :error_html=>{:class=>"bar"}, :hint=>"foo", :hint_tag=>"p", :hint_html=>{:class=>"bar"}, :label=>"foo", :label_html=>{:class=>"bar"}, :class=>[:string, :optional]}" label="foo" input_html="{:class=>[:string, :optional, [:string, :optional, [:string, :optional, "bar"]]], :size=>50}" input="foo" hint_html="{:class=>"bar"}" error_html="{:class=>"bar"}" error="foo">foo

```

## quick solution

I found that checking wether the options has the key `:hint_hml` or `:label_html`, completely clean up the html output:

```rb
# lib/simple_form/form_builder.rb

# inside the hint method line:
options[:hint_html] = options.except(:hint_tag, :hint) unless options.has_key?(:hint_html)

# inside the label method line:
options[:label_html] = options.except(:label, :required) unless options.has_key?(:label_html)
```

Would this work for `:error_html` as well? Also it's interesting that `:input_html` is already working as expected.