forked from bootstrap-ruby/bootstrap_form
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollection_check_boxes.rb
More file actions
30 lines (26 loc) · 975 Bytes
/
collection_check_boxes.rb
File metadata and controls
30 lines (26 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true
module BootstrapForm
module Inputs
module CollectionCheckBoxes
extend ActiveSupport::Concern
include Base
include InputsCollection
included do
def collection_check_boxes_with_bootstrap(*args)
args[4]&.delete(:id)
html = inputs_collection(*args) do |name, value, options|
options[:multiple] = true
check_box(name, options, value, nil)
end
if args.extract_options!.symbolize_keys!.delete(:include_hidden) { true }
html.prepend hidden_field(args.first, value: "", name: field_name(args[0], multiple: true))
end
html
end
bootstrap_alias :collection_check_boxes
alias_method :collection_checkboxes_with_bootstrap, :collection_check_boxes_with_bootstrap if Rails::VERSION::MAJOR >= 8
bootstrap_alias :collection_checkboxes if Rails::VERSION::MAJOR >= 8
end
end
end
end