Module: Playbook::PbForm::FormBuilder::CheckboxField

Defined in:
app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb

Instance Method Summary collapse

Instance Method Details

#check_box(name, props: {}, **options, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb', line 7

def check_box(name, props: {}, **options, &block)
  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

  input = super(name, **options, &block)

  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