Sha256: 1c739822baa29f430b6cd4ada096888547a325da62cb2fd79b0aea042107ec93

Contents?: true

Size: 981 Bytes

Versions: 2

Compression:

Stored size: 981 Bytes

Contents

module Trestle
  class Form
    module Fields
      module CheckBoxHelpers
        def custom?
          options[:custom] != false
        end

        def switch?
          options[:switch]
        end

        def inline?
          options[:inline]
        end

        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

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
trestle-0.9.1 lib/trestle/form/fields/check_box_helpers.rb
trestle-0.9.0 lib/trestle/form/fields/check_box_helpers.rb