Class: OkonomiUiKit::Components::Forms::Select

Inherits:
FormComponent show all
Defined in:
app/helpers/okonomi_ui_kit/components/forms/select.rb

Instance Attribute Summary

Attributes inherited from OkonomiUiKit::Component

#view

Instance Method Summary collapse

Methods inherited from FormComponent

namespace

Methods inherited from OkonomiUiKit::Component

#combined_styles, config_class?, config_class_name, config_classes, config_namespace, #config_styles_registry, config_styles_registry, deep_merge, #initialize, #internal_styles_registry, internal_styles_registry, #name, parent_styles_registry, register_styles, resolve_config_classes, #style, #styles, #template_path, #theme_name, #tw_merge, #variant_style

Constructor Details

This class inherits a constructor from OkonomiUiKit::Component

Instance Method Details

#render(form, method, choices = nil, options = {}, html_options = {}, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/helpers/okonomi_ui_kit/components/forms/select.rb', line 5

def render(form, method, choices = nil, options = {}, html_options = {}, &block)
  html_options = html_options.with_indifferent_access
  css = build_select_classes(form, method, html_options)

  select_html = ActionView::Helpers::FormBuilder.instance_method(:select).bind(form).call(method, choices, options, html_options.merge(class: css), &block)
  icon_html = view.ui.icon(
    style(:icon, :file),
    class: style(:icon, :class)
  )

  view.(:div, class: style(:wrapper)) do
    view.concat(select_html)
    view.concat(icon_html)
  end
end