Sha256: 987e66caf16d360fecba33302a3f12a9ede7ab361d39d6febab131319de9b5fa

Contents?: true

Size: 732 Bytes

Versions: 4

Compression:

Stored size: 732 Bytes

Contents

module Surveyor
  module Helpers
    module FormtasticCustomInput
      def input_html_options_with(choice, response_class)
        input_html_options.merge(choice_html_options(choice)).merge({:id => (input_html_options[:id] || "answer_id").gsub("answer_id", response_class_to_method(response_class).to_s), :class => [input_html_options[:class], response_class].join(" ")})
      end
      def response_class_to_method(response_class)
        # doesn't handle response_class == answer, and doesn't have to
        case response_class.to_s
        when /^other_and_string$/ then :string_value
        when /^date|time$/ then :datetime_value
        else "#{response_class}_value".to_sym
        end
      end      
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
surveyor-1.2.0 lib/surveyor/helpers/formtastic_custom_input.rb
surveyor-1.1.0 lib/surveyor/helpers/formtastic_custom_input.rb
surveyor-1.0.1 lib/surveyor/helpers/formtastic_custom_input.rb
surveyor-1.0.0 lib/surveyor/helpers/formtastic_custom_input.rb