Class: Effective::FormInputs::CheckBox

Inherits:
Effective::FormInput show all
Defined in:
app/models/effective/form_inputs/check_box.rb

Constant Summary

Constants inherited from Effective::FormInput

Effective::FormInput::BLANK, Effective::FormInput::EXCLUSIVE_CLASS_PREFIXES, Effective::FormInput::EXCLUSIVE_CLASS_SUFFIXES

Instance Attribute Summary

Attributes inherited from Effective::FormInput

#name, #options

Instance Method Summary collapse

Methods inherited from Effective::FormInput

#feedback_options, #hint_options, #initialize, #input_group_options, #input_js_options, #wrapper_options

Constructor Details

This class inherits a constructor from Effective::FormInput

Instance Method Details

#build_check_box_wrap(&block) ⇒ Object



20
21
22
23
24
25
26
# File 'app/models/effective/form_inputs/check_box.rb', line 20

def build_check_box_wrap(&block)
  if custom?
    (:div, yield, class: 'form-group custom-control custom-checkbox' + (inline? ? ' custom-control-inline' : ''))
  else
    (:div, yield, class: 'form-check' + (inline? ? ' form-check-inline' : ''))
  end
end

#build_content(&block) ⇒ Object



16
17
18
# File 'app/models/effective/form_inputs/check_box.rb', line 16

def build_content(&block)
  build_check_box_wrap { build_input(&block) + build_label + build_feedback + build_hint }
end

#input_html_optionsObject



36
37
38
39
40
41
42
# File 'app/models/effective/form_inputs/check_box.rb', line 36

def input_html_options
  if custom?
    { class: 'custom-control-input', id: unique_id }
  else
    { class: 'form-check-input', id: unique_id }
  end
end

#label_optionsObject



28
29
30
31
32
33
34
# File 'app/models/effective/form_inputs/check_box.rb', line 28

def label_options
  if custom?
    { class: 'custom-control-label' }
  else
    { class: 'form-check-label' }
  end
end

#to_html(&block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'app/models/effective/form_inputs/check_box.rb', line 5

def to_html(&block)
  case layout
  when :horizontal
    build_wrapper do
      (:div, '', class: 'col-sm-2') + (:div, build_content(&block), class: 'col-sm-10')
    end
  else
    build_content(&block)
  end
end