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::DEFAULT_FEEDBACK_OPTIONS, Effective::FormInput::DEFAULT_INPUT_GROUP_OPTIONS, Effective::FormInput::EMPTY_HASH, Effective::FormInput::EXCLUSIVE_CLASS_PREFIXES, Effective::FormInput::EXCLUSIVE_CLASS_SUFFIXES, Effective::FormInput::HORIZONTAL_LABEL_OPTIONS, Effective::FormInput::HORIZONTAL_WRAPPER_OPTIONS, Effective::FormInput::INLINE_LABEL_OPTIONS, Effective::FormInput::VERTICAL_WRAPPER_OPTIONS

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



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

def build_check_box_wrap(&block)
  if custom?
    (:div, yield, options[:wrapper])
  else
    (:div, yield, options[:wrapper])
  end
end

#build_content(&block) ⇒ Object



18
19
20
# 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_optionsObject



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

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



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

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

#to_html(&block) ⇒ Object



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

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



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

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