Class: Shoelace::Components::SlSwitch

Inherits:
ActionView::Helpers::Tags::NumberField
  • Object
show all
Includes:
ErrorWrappable
Defined in:
app/helpers/shoelace/components/sl_switch.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from ErrorWrappable

#error_wrapping

Instance Method Details

#field_typeObject



10
# File 'app/helpers/shoelace/components/sl_switch.rb', line 10

def field_type; nil; end

#render(&block) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'app/helpers/shoelace/components/sl_switch.rb', line 12

def render(&block)
  options = @options.stringify_keys
  options["value"] = options.fetch("value") { value_before_type_cast }
  add_default_name_and_id(options)
  label = options.delete('label').presence
  options["invalid"] = options["data-invalid"] = "" if object_has_errors?

  ('sl-switch', label, options, &block)
end