Sha256: 840dc2e0e70590c2f9560978c88498eb8b0a56840215e71e78272f364aa3801b

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

# -*- encoding: utf-8 -*-
# -*- frozen_string_literal: true -*-
# -*- warn_indent: true -*-

module RailsBootstrapForm
  module Inputs
    module CheckBox
      extend ActiveSupport::Concern

      included do
        def check_box(attribute, options = {}, checked_value = "1", unchecked_value = "0")
          bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
          return super if bootstrap.disabled?

          check_box_html = tag.div(class: choice_wrapper_classes(bootstrap)) do
            concat(bootstrap_check_box(attribute, checked_value, options, bootstrap))
            concat(help_text(attribute, bootstrap))
            concat(generate_error(attribute)) if is_invalid?(attribute)
          end

          if bootstrap.wrapper
            tag.div(**field_wrapper_options(bootstrap)) do
              if bootstrap.layout_horizontal?
                tag.div(class: choice_container_classes(bootstrap)) { check_box_html }
              else
                check_box_html
              end
            end
          else
            check_box_html
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails_bootstrap_form-0.9.7 lib/rails_bootstrap_form/inputs/check_box.rb
rails_bootstrap_form-0.9.6 lib/rails_bootstrap_form/inputs/check_box.rb
rails_bootstrap_form-0.9.5 lib/rails_bootstrap_form/inputs/check_box.rb
rails_bootstrap_form-0.9.4 lib/rails_bootstrap_form/inputs/check_box.rb
rails_bootstrap_form-0.9.3 lib/rails_bootstrap_form/inputs/check_box.rb