Skip to content

Instantly share code, notes, and snippets.

@camallen
Created September 29, 2012 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camallen/3803552 to your computer and use it in GitHub Desktop.
Save camallen/3803552 to your computer and use it in GitHub Desktop.
Custom simple form Hash field input
#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
@stevenwanderski
Copy link

Exactly what I needed. Perfect fit. Thanks!

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