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

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



24
25
26
27
28
29
30
# File 'app/models/effective/form_inputs/check_box.rb', line 24

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



18
19
20
21
22
# File 'app/models/effective/form_inputs/check_box.rb', line 18

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

#input_html_options ⇒ Object



40
41
42
43
44
45
46
# File 'app/models/effective/form_inputs/check_box.rb', line 40

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

#label_options ⇒ Object



32
33
34
35
36
37
38
# File 'app/models/effective/form_inputs/check_box.rb', line 32

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
15
16
# 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, class: 'col-sm-10') do
        build_content(&block)
      end
    end
  else
    build_content(&block)
  end
end