Class: Matestack::Ui::Bootstrap::Form::Radio

Inherits:
VueJs::Components::Form::Radio
  • Object
show all
Includes:
Registry
Defined in:
lib/matestack/ui/bootstrap/form/radio.rb

Instance Method Summary collapse

Methods included from Registry

#bs_accordion, #bs_alert, #bs_avatar, #bs_badge, #bs_breadcrumb, #bs_btn, #bs_btn_group, #bs_card, #bs_carousel, #bs_close, #bs_col, #bs_collapse, #bs_container, #bs_dropdown, #bs_figure, #bs_form_checkbox, #bs_form_input, #bs_form_radio, #bs_form_select, #bs_form_submit, #bs_form_switch, #bs_icon, #bs_list_group, #bs_modal, #bs_navbar, #bs_page_heading, #bs_pagination, #bs_popover, #bs_progress, #bs_row, #bs_scrollspy, #bs_section_card, #bs_sidebar, #bs_smart_collection, #bs_spinner, #bs_tab_nav, #bs_tab_nav_content, #bs_toast, #bs_tooltip

Instance Method Details

#bootstrap_radio_attributesObject



30
31
32
33
34
35
# File 'lib/matestack/ui/bootstrap/form/radio.rb', line 30

def bootstrap_radio_attributes
  {
    class: (options[:class] || "") << (" form-check-input"),
    disabled: context.disabled
  }
end

#input_error_classObject



51
52
53
# File 'lib/matestack/ui/bootstrap/form/radio.rb', line 51

def input_error_class
  'is-invalid'
end

#render_errorsObject



43
44
45
46
47
48
49
# File 'lib/matestack/ui/bootstrap/form/radio.rb', line 43

def render_errors
  if display_errors?
    div class: 'invalid-feedback', 'v-for': "error in #{error_key}", style: "display: block;" do
      plain '{{ error }}'
    end
  end
end

#render_form_textObject



37
38
39
40
41
# File 'lib/matestack/ui/bootstrap/form/radio.rb', line 37

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

#responseObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/matestack/ui/bootstrap/form/radio.rb', line 11

def response
  div class: "matestack-ui-bootstrap-radio" do
    label input_label, class: "form-label" if input_label

    radio_options.to_a.each_with_index do |item, index|
      div class: "form-check #{'form-check-inline' if context.variant == :inline}" do
        input options.merge(radio_attributes(item)).merge(bootstrap_radio_attributes)
        label item_label(item), class: "form-check-label", for: item_id(item_value(item))
        if index == radio_options.to_a.size - 1
          render_errors
        end
      end
    end
    render_form_text if context.form_text
  end

end