lib/formtastic/helpers/input_helper.rb in formtastic-3.1.3 vs lib/formtastic/helpers/input_helper.rb in formtastic-3.1.4

- old
+ new

@@ -38,10 +38,11 @@ module InputHelper INPUT_CLASS_DEPRECATION = 'configure Formtastic::FormBuilder.input_class_finder instead (upgrade guide on wiki: http://bit.ly/1F9QtKc )'.freeze private_constant(:INPUT_CLASS_DEPRECATION) include Formtastic::Helpers::Reflection + include Formtastic::Helpers::Enum include Formtastic::Helpers::FileColumnDetection # Returns a chunk of HTML markup for a given `method` on the form object, wrapped in # an `<li>` wrapper tag with appropriate `class` and `id` attribute hooks for CSS and JS. # In many cases, the contents of the wrapper will be as simple as a `<label>` and an `<input>`: @@ -132,10 +133,11 @@ # @option options :required [Boolean] # Override to mark the input as required (or not) — adds a required/optional class to the wrapper, and a HTML5 required attribute to the `<input>` # # @option options :input_html [Hash] # Override or add to the HTML attributes to be passed down to the `<input>` tag + # (If you use attr_readonly method in your model, formtastic will automatically set those attributes's input readonly) # # @option options :wrapper_html [Hash] # Override or add to the HTML attributes to be passed down to the wrapping `<li>` tag # # @option options :collection [Array<ActiveModel, String, Symbol>, Hash{String => String, Boolean}, OrderedHash{String => String, Boolean}] @@ -257,11 +259,12 @@ return :select if reflection_for(method) return :file if is_file?(method, options) end - if column = column_for(method) + column = column_for(method) + if column && column.type # Special cases where the column type doesn't map to an input method. case column.type when :string return :password if method.to_s =~ /password/ return :country if method.to_s =~ /country$/ @@ -271,9 +274,10 @@ return :phone if method.to_s =~ /(phone|fax)/ return :search if method.to_s =~ /^search$/ return :color if method.to_s =~ /color/ when :integer return :select if reflection_for(method) + return :select if enum_for(method) return :number when :float, :decimal return :number when :datetime, :timestamp return :datetime_select