Sha256: 74ccdf354685cce5f018456c34809ea5661c9e7fcf04608149eb3b71898c3968

Contents?: true

Size: 1.01 KB

Versions: 103

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbForm
    module FormBuilder
      module CheckboxField
        def check_box(name, props: {}, **options)
          label_text = @template.label(@object_name, name) if props[:label] == true
          options[:required] = true if props[:required]
          props[:margin_bottom] = "sm"
          props[:form_spacing] = true

          checked_value = options[:checked_value]
          unchecked_value = options[:unchecked_value]
          options.delete(:checked_value)
          options.delete(:unchecked_value)

          input = super(name, options, checked_value, unchecked_value)

          if props[:label]
            @template.pb_rails("caption", props: { text: label_text, margin_bottom: "xs" }) +
              @template.pb_rails("checkbox", props: props) do
                input
              end
          else
            @template.pb_rails("checkbox", props: props) do
              input
            end
          end
        end
      end
    end
  end
end

Version data entries

103 entries across 103 versions & 1 rubygems

Version Path
playbook_ui-7.6.0 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb
playbook_ui-7.5.1 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb
playbook_ui-7.5.0 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb
playbook_ui-7.4.2 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb
playbook_ui-7.4.1 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb
playbook_ui-7.4.0.pre.alpha6 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb
playbook_ui-7.4.0.pre.alpha5 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb
playbook_ui-7.4.0 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb
playbook_ui-7.4.0.pre.test4 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb
playbook_ui-7.4.0.pre.test3 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb
playbook_ui-7.4.0.pre.test2 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb
playbook_ui-7.4.0.pre.alpha4 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb
playbook_ui-7.4.0.pre.alpha2 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb
playbook_ui-7.4.0.pre.alpha1 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb
playbook_ui-7.3.0.pre.alpha12 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb
playbook_ui-7.3.0 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb
playbook_ui-7.3.0.pre.alpha11 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb
playbook_ui-7.3.0.pre.alpha10 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb
playbook_ui-7.3.0.pre.alpha9 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb
playbook_ui-7.3.0.pre.alpha8 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb