1- require 'formtastic'
2-
31module ActiveAdmin
4- class FormBuilder < ::Formtastic ::SemanticFormBuilder
2+ class FormBuilder < ::Formtastic ::FormBuilder
53
64 attr_reader :form_buffers
75
@@ -21,8 +19,6 @@ def inputs(*args, &block)
2119 # its contents, so we want to skip the internal buffering
2220 # while building up its contents
2321 def input ( method , *args )
24- return if polymorphic_belongs_to_association? ( method )
25-
2622 content = with_new_form_buffer { super }
2723 return content . html_safe unless @inputs_with_block
2824 form_buffers . last << content . html_safe
@@ -52,14 +48,6 @@ def commit_button_with_cancel_link
5248 content << cancel_link
5349 end
5450
55- def datepicker_input ( method , options )
56- options = options . dup
57- options [ :input_html ] ||= { }
58- options [ :input_html ] [ :class ] = [ options [ :input_html ] [ :class ] , "datepicker" ] . compact . join ( ' ' )
59- options [ :input_html ] [ :size ] ||= "10"
60- string_input ( method , options )
61- end
62-
6351 def has_many ( association , options = { } , &block )
6452 options = { :for => association } . merge ( options )
6553 options [ :class ] ||= ""
@@ -98,15 +86,14 @@ def has_many(association, options = {}, &block)
9886 form_buffers . last << content . html_safe
9987 end
10088
101- private
89+ protected
10290
103- # Pass in a method to check if it's a polymorphic association
104- def polymorphic_belongs_to_association? ( method )
105- reflection = reflection_for ( method )
106-
107- reflection && reflection . macro == :belongs_to && reflection . options [ :polymorphic ]
91+ def custom_input_class_name ( as )
92+ "ActiveAdmin::Inputs::#{ as . to_s . camelize } Input"
10893 end
10994
95+ private
96+
11097 def with_new_form_buffer
11198 form_buffers << "" . html_safe
11299 return_value = yield
0 commit comments