Skip to content

Small refactor: add `raw_input` method to make testing custom inputs easier #850

Closed
wants to merge 1 commit into from
View
10 lib/formtastic/helpers/input_helper.rb
@@ -232,16 +232,20 @@ module InputHelper
# @todo Many many more examples. Some of the detail probably needs to be pushed out to the relevant methods too.
# @todo More i18n examples.
def input(method, options = {})
+ raw_input(method, options).to_html
+ end
+
+ protected
+
+ def raw_input(method, options = {})
options = options.dup # Allow options to be shared without being tainted by Formtastic
options[:as] ||= default_input_type(method, options)
klass = input_class(options[:as])
- klass.new(self, template, @object, @object_name, method, options).to_html
+ klass.new(self, template, @object, @object_name, method, options)
end
- protected
-
# First try if we can detect special things like :file. With CarrierWave the method does have
# an underlying column so we don't want :string to get selected.
#
Something went wrong with that request. Please try again.