This patch adds a backwards compatible change to ActionView::Helpers::FormOptionsHelper, regarding option hashes.
In the current trunk of rails, this is how you add options to the html tag on e.g. collection_select:
collection_select(:category_id, @categories, 'id', 'title', {}, :class => "cool")
In other words, there's two option hashes on that method. This is annoying because:
- It nerfs the looks of the otherwise beautiful last-argument-as-option-hash way of writing methods in Ruby
- It's impossible to add options properly using with_options scopes
- It's not what people expect - other methods, such as form_for, is using :html => {:separate => "hash"} to do this.
This patch improves the behavior of the select methods by letting people use one option hash and specify html options in a hash, stored in the :html key of the original options hash.
collection_select(:category_id, @categories, 'id', 'title', :html => {:class => "cool"})
It's also backwards compatible, so it won't break the existing way of using two option hashes. This is done by parsing *args.
Tests are written, patch attached.