Class: Matestack::Ui::Bootstrap::Form::Select

Inherits:
Core::Form::Select::Base
  • Object
show all
Defined in:
app/concepts/matestack/ui/bootstrap/form/select.rb

Instance Method Summary collapse

Instance Method Details

#form_select_classObject



20
21
22
23
24
25
26
27
28
29
# File 'app/concepts/matestack/ui/bootstrap/form/select.rb', line 20

def form_select_class
  case variant
  when :lg
    (options[:class] || "") << (" form-select form-select-lg")
  when :sm
    (options[:class] || "") << (" form-select form-select-sm")
  else
    (options[:class] || "") << (" form-select")
  end
end

#input_error_classObject



43
44
45
# File 'app/concepts/matestack/ui/bootstrap/form/select.rb', line 43

def input_error_class
  'is-invalid'
end

#render_errorsObject



35
36
37
38
39
40
41
# File 'app/concepts/matestack/ui/bootstrap/form/select.rb', line 35

def render_errors
  unless @included_config[:errors] == false && (errors == false || errors.nil?) || errors == false
    div class: 'invalid-feedback', attributes: { 'v-for': "error in #{error_key}" } do
      plain '{{ error }}'
    end
  end
end

#render_form_textObject



47
48
49
50
51
# File 'app/concepts/matestack/ui/bootstrap/form/select.rb', line 47

def render_form_text
  div id: "form_text_for_#{attr_key}", class: "form-text" do
    plain form_text
  end
end

#responseObject



9
10
11
12
13
14
15
16
17
18
# File 'app/concepts/matestack/ui/bootstrap/form/select.rb', line 9

def response
  div class: "matestack-ui-bootstrap-form-select" do
    label for: attr_key,  class: "form-label", text: input_label if input_label
    select select_attributes.merge({ id: (options[:id] || attr_key), class: form_select_class, size: size_class }) do
      render_options
    end
    render_errors
    render_form_text
  end
end

#size_classObject



31
32
33
# File 'app/concepts/matestack/ui/bootstrap/form/select.rb', line 31

def size_class
  size
end