Class: Formatic::Select

Inherits:
Base show all
Defined in:
app/components/formatic/select.rb

Overview

Dropdown box

Instance Method Summary collapse

Methods inherited from Base

#input_name, #param_key, #value, #wrapper

Methods inherited from ApplicationComponent

#initialize

Constructor Details

This class inherits a constructor from Formatic::ApplicationComponent

Instance Method Details

#choicesObject



27
28
29
30
31
32
33
34
35
36
37
# File 'app/components/formatic/select.rb', line 27

def choices
  ::Formatic::Choices.call(
    f:,
    attribute_name:,
    options:,
    records:,
    keys:,
    include_current:,
    include_blank: include_blank?
  )
end

#current_choice_nameObject



39
40
41
# File 'app/components/formatic/select.rb', line 39

def current_choice_name
  choices.detect { it.last == value }&.first
end

#include_blank?Boolean

Returns:

  • (Boolean)


43
44
45
46
47
# File 'app/components/formatic/select.rb', line 43

def include_blank?
  return wrapper.optional? if @include_blank == :guess

  !!@include_blank
end