Sha256: 7e754bf4f0df3974911da96b77b53df2f611926425a0e9e53c802ab68a4613cf

Contents?: true

Size: 771 Bytes

Versions: 42

Compression:

Stored size: 771 Bytes

Contents

module ExpressTemplates
  module Components
    module Forms
      class Checkbox < FormComponent

        has_option :label_after, 'Positions the option label after the checkbox.', default: false

        contains {
          label_tag(label_name, label_text) if label_before?
          check_box(resource_name, field_name.to_sym, field_options, checked_value, unchecked_value)
          label_tag(label_name, label_text) if label_after?
        }

        def label_before?
          !label_after?
        end

        def label_after?
          !!config[:label_after]
        end

        def field_options
          {}
        end

        def checked_value
          "1"
        end

        def unchecked_value
          "0"
        end

      end
    end
  end
end

Version data entries

42 entries across 42 versions & 2 rubygems

Version Path
express_admin-1.5.0 vendor/gems/express_templates/lib/express_templates/components/forms/checkbox.rb
express_admin-1.4.11 vendor/gems/express_templates/lib/express_templates/components/forms/checkbox.rb