Sha256: 90b033dd43b5487c82863e295f75a8c2c11003361f345ed8d59d91c0d81500a1

Contents?: true

Size: 996 Bytes

Versions: 26

Compression:

Stored size: 996 Bytes

Contents

require 'action_view/helpers/tags/placeholderable'

module RedmineExtensions
  module Tags
    class AutocompleteField < ActionView::Helpers::Tags::Base
      include ActionView::Helpers::Tags::Placeholderable

      def initialize(object_name, method_name, template_object, choices, options, html_options)
        @choices = block_given? ? template_object.capture { yield || "" } : choices
        @choices = @choices.to_a if @choices.is_a?(Range)

        options[:multiple] = true unless options.key?(:multiple)

        @html_options = html_options

        super(object_name, method_name, template_object, html_options.merge(options))
      end

      def render
        options = @options.stringify_keys
        options["value"] = options.fetch("value") { value_before_type_cast(object) }
        add_default_name_and_id(options)
        @template_object.autocomplete_field_tag(options.delete('name'), @choices, options.delete('value'), options.symbolize_keys)
      end

    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
redmine_extensions-0.3.00 lib/redmine_extensions/tags/autocomplete_field.rb
redmine_extensions-0.2.16 lib/redmine_extensions/tags/autocomplete_field.rb
redmine_extensions-0.2.14 lib/redmine_extensions/tags/autocomplete_field.rb
redmine_extensions-0.2.13 lib/redmine_extensions/tags/autocomplete_field.rb
redmine_extensions-0.2.12 lib/redmine_extensions/tags/autocomplete_field.rb
redmine_extensions-0.2.11 lib/redmine_extensions/tags/autocomplete_field.rb
redmine_extensions-0.2.10 lib/redmine_extensions/tags/autocomplete_field.rb
redmine_extensions-0.2.9 lib/redmine_extensions/tags/autocomplete_field.rb
redmine_extensions-0.2.8 lib/redmine_extensions/tags/autocomplete_field.rb
redmine_extensions-0.2.7 lib/redmine_extensions/tags/autocomplete_field.rb
redmine_extensions-0.2.6 lib/redmine_extensions/tags/autocomplete_field.rb
redmine_extensions-0.2.5 lib/redmine_extensions/tags/autocomplete_field.rb
redmine_extensions-0.2.4 lib/redmine_extensions/tags/autocomplete_field.rb
redmine_extensions-0.2.3 lib/redmine_extensions/tags/autocomplete_field.rb
redmine_extensions-0.2.2 lib/redmine_extensions/tags/autocomplete_field.rb
redmine_extensions-0.2.0 lib/redmine_extensions/tags/autocomplete_field.rb
redmine_extensions-0.1.27 lib/redmine_extensions/tags/autocomplete_field.rb
redmine_extensions-0.1.26 lib/redmine_extensions/tags/autocomplete_field.rb
redmine_extensions-0.1.25 lib/redmine_extensions/tags/autocomplete_field.rb
redmine_extensions-0.1.24 lib/redmine_extensions/tags/autocomplete_field.rb