Method: Redmineup::FormTagHelper#transform_to_select2

Defined in:
lib/redmineup/helpers/form_tag_helper.rb

#transform_to_select2(type, options = {}) ⇒ Object

Transforms select filters of type fields into select2

Examples

transform_to_select2 'tags', url: auto_complete_tags_url
transform_to_select2 'people', format_state: 'formatStateWithAvatar', min_input_length: 1, url: '/managers'

Options

  • :url Defines URL to search remote data using the ajax.

  • :format_state Defines template of search results in the drop-down.

  • :min_input_length Minimum number of characters required to start a search. Default value 0.

  • :width Sets the width of the control. Default value ‘60%’.

  • :multiple Supports multi-value select box. If set to false the selection will not allow multiple choices. Default value true.

Note: Select2 assets must be available on a page.

To include select2 assets to a page, you need to use the helper select2_assets.
For example:
  <% content_for :header_tags do %>
    <%= select2_assets %>
  <% end %>


72
73
74
# File 'lib/redmineup/helpers/form_tag_helper.rb', line 72

def transform_to_select2(type, options = {})
  javascript_tag("setSelect2Filter('#{type}', #{options.to_json});") unless type.empty?
end