Created
September 29, 2012 09:24
-
-
Save camallen/3803552 to your computer and use it in GitHub Desktop.
Custom simple form Hash field input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Simple form Input class for a hash | |
class HashInput < SimpleForm::Inputs::Base | |
def input | |
key = input_html_options.delete(:key) | |
#override the params to be in the format that rails will auto correlate back to an | |
# attribute hash with key: value | |
input_html_options.merge!({:name => "#{self.object_name}[#{attribute_name}][#{key}]"}) | |
@builder.text_field(attribute_name, input_html_options) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Exactly what I needed. Perfect fit. Thanks!