Module: Trestle::Form::Fields::CheckBoxHelpers

Included in:
CheckBox, CollectionCheckBoxes
Defined in:
lib/trestle/form/fields/check_box_helpers.rb

Instance Method Summary collapse

Instance Method Details

#custom?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/trestle/form/fields/check_box_helpers.rb', line 5

def custom?
  options[:custom] != false
end

#default_wrapper_classObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/trestle/form/fields/check_box_helpers.rb', line 17

def default_wrapper_class
  if custom?
    [
      "custom-control",
      switch? ? "custom-switch" : "custom-checkbox",
      ("custom-control-inline" if inline?)
    ].compact
  else
    [
      "form-check",
      ("form-check-inline" if inline?)
    ].compact
  end
end

#defaultsObject



40
41
42
# File 'lib/trestle/form/fields/check_box_helpers.rb', line 40

def defaults
  Trestle::Options.new(disabled: readonly?)
end

#inline?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/trestle/form/fields/check_box_helpers.rb', line 13

def inline?
  options[:inline]
end

#input_classObject



32
33
34
# File 'lib/trestle/form/fields/check_box_helpers.rb', line 32

def input_class
  custom? ? ["custom-control-input"] : ["form-check-input"]
end

#label_classObject



36
37
38
# File 'lib/trestle/form/fields/check_box_helpers.rb', line 36

def label_class
  custom? ? ["custom-control-label"] : ["form-check-label"]
end

#switch?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/trestle/form/fields/check_box_helpers.rb', line 9

def switch?
  options[:switch]
end