Sha256: 586cfe9f99d8e095d9ad07c48b96d607768889a1087745b60faf2789c1919662

Contents?: true

Size: 852 Bytes

Versions: 1

Compression:

Stored size: 852 Bytes

Contents

# frozen_string_literal: true

module Playbook
  module PbForm
    module FormBuilder
      module CheckboxField
        def check_box(name, data: {}, props: {})
          value = props[:value] ||= 1
          input = super(name, { required: props[:required], data: data }, value)
          label_text = name.to_s.gsub("_", " ")

          props[:margin_bottom] = "sm"
          props[:form_spacing] = true

          # Refactor and dry up, solve adding nil error
          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

1 entries across 1 versions & 1 rubygems

Version Path
playbook_ui-6.1.0.pre.alpha3 app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb