class Trestle::Form::Fields::CheckBox

Attributes

checked_value[R]
unchecked_value[R]

Public Class Methods

new(builder, template, name, options = {}, checked_value = "1", unchecked_value = "0") click to toggle source
Calls superclass method Trestle::Form::Field::new
# File lib/trestle/form/fields/check_box.rb, line 9
def initialize(builder, template, name, options = {}, checked_value = "1", unchecked_value = "0")
  super(builder, template, name, options)
  @checked_value, @unchecked_value = checked_value, unchecked_value
end

Public Instance Methods

extract_wrapper_options!() click to toggle source
# File lib/trestle/form/fields/check_box.rb, line 30
def extract_wrapper_options!
  # Intentional no-op
end
field() click to toggle source
# File lib/trestle/form/fields/check_box.rb, line 18
def field
  wrapper_class = options.delete(:class)
  wrapper_class = default_wrapper_class if wrapper_class.empty?

  content_tag(:div, class: wrapper_class) do
    safe_join([
      builder.raw_check_box(name, options.merge(class: input_class), checked_value, unchecked_value),
      builder.label(name, options[:label] || admin.human_attribute_name(name), class: label_class, value: (checked_value if options[:multiple]))
    ])
  end
end
render() click to toggle source
# File lib/trestle/form/fields/check_box.rb, line 14
def render
  field
end