class UiBibz::Ui::Core::Forms::Texts::AutoCompleteField

Create a AutoCompleteField

This element is an extend of UiBibz::Ui::Core::Component.

Attributes

Options

You can add HTML attributes using the html_options. You can pass arguments in options attribute:

Signatures

UiBibz::Ui::Core::Forms::Texts::AutoCompleteField.new(content, options = {}, html_options = {}).render

UiBibz::Ui::Core::Forms::Texts::AutoCompleteField.new(options = {}, html_options = {}) do
  content
end.render

Examples

options = options_for_select(Array.new(2){ |i| "option #{i}" })
UiBibz::Ui::Core::Forms::Texts::AutoCompleteField.new('company', { option_tags: options }, { class: 'test' })

options = options_for_select(Array.new(2){ |i| "option #{i}" })
UiBibz::Ui::Core::Forms::Texts::AutoCompleteField.new(option_tags: options) do
  #content
end

Helper

auto_complete_field(options = {}, html_options = {}) do
 # content
end

Private Instance Methods

component_html_classes() click to toggle source
# File lib/ui_bibz/ui/core/forms/texts/auto_complete_field.rb, line 64
def component_html_classes
  super << 'auto-complete-field'
end
component_html_options() click to toggle source
# File lib/ui_bibz/ui/core/forms/texts/auto_complete_field.rb, line 60
def component_html_options
  { autocomplete: true, list: data_list_name, disabled: options[:state] }
end
connect_options_selector() click to toggle source

Connect option

# File lib/ui_bibz/ui/core/forms/texts/auto_complete_field.rb, line 73
def connect_options_selector
  data_list_name
end
data_list_name() click to toggle source
# File lib/ui_bibz/ui/core/forms/texts/auto_complete_field.rb, line 68
def data_list_name
  @data_list_name ||= "#{html_options[:id] || content.to_s.parameterize.underscore}-datalist"
end
data_list_render() click to toggle source
# File lib/ui_bibz/ui/core/forms/texts/auto_complete_field.rb, line 56
def data_list_render
  content_tag :datalist, options[:option_tags], id: data_list_name
end
text_field_input_tag() click to toggle source

See UiBibz::Ui::Core::Component.initialize

# File lib/ui_bibz/ui/core/forms/texts/auto_complete_field.rb, line 52
def text_field_input_tag
  text_field_tag(content, options[:value] || html_options[:value], html_options) + data_list_render
end