Class: Effective::FormInputs::CheckBox
Constant Summary
Effective::FormInput::BLANK, Effective::FormInput::EXCLUSIVE_CLASS_PREFIXES, Effective::FormInput::EXCLUSIVE_CLASS_SUFFIXES
Instance Attribute Summary
#name, #options
Instance Method Summary
collapse
#feedback_options, #hint_options, #initialize, #input_group_options, #input_js_options
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?
content_tag(:div, yield, options[:wrapper])
else
content_tag(: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
|
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_options ⇒ Object
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
content_tag(:div, '', class: 'col-sm-2') + content_tag(:div, build_content(&block), class: 'col-sm-10')
end
else
build_content(&block)
end
end
|
#wrapper_options ⇒ Object
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
|