Sha256: 637788c6df085481f219da93e81ec7e0393e9bb5e2e20c67e3ad78914f33e5f1

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

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

module RailsBootstrapForm
  module Inputs
    module CollectionCheckBoxes
      extend ActiveSupport::Concern

      included do
        def collection_check_boxes(attribute, collection, value_method, text_method, options = {}, html_options = {})
          bootstrap = bootstrap_form_options.scoped(options.delete(:bootstrap))
          return super if bootstrap.disabled?

          bootstrap.disable_floating_labels!

          inputs = inputs_collection(attribute, collection, value_method, text_method, bootstrap, options) do |attribute, value, options|
            bootstrap_opts = bootstrap_form_options.scoped(options.delete(:bootstrap))

            tag.div(class: choice_wrapper_classes(bootstrap_opts)) do
              bootstrap_check_box(attribute, value, options, bootstrap_opts)
            end
          end

          if options.delete(:include_hidden) { true }
            inputs.prepend(hidden_field(attribute, value: "", multiple: options[:multiple]))
          end

          field_wrapper_builder(attribute, bootstrap, options, html_options) do
            concat(tag.div(class: control_specific_class(:collection_check_boxes)) do
              concat(inputs)
            end)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_bootstrap_form-0.9.5 lib/rails_bootstrap_form/inputs/collection_check_boxes.rb