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

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, options[:wrapper])
  else
    (:div, yield, options[:wrapper])
  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



48
49
50
51
52
53
54
# File 'app/models/effective/form_inputs/check_box.rb', line 48

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



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

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

#wrapper_optionsObject



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

def wrapper_options
  if custom? && inline?
    { class: 'form-group custom-control custom-checkbox custom-control-inline' }
  elsif custom?
    { class: 'form-group custom-control custom-checkbox' }
  elsif inline?
    { class: 'form-check form-check-inline' }
  else
    { class: 'form-check' }
  end
end