Class: Formtastic::Inputs::PrismToggleInput

Inherits:
BooleanInput
  • Object
show all
Defined in:
lib/formtastic/inputs/prism_toggle_input.rb

Overview

An opt-in boolean input rendered as an iOS-style switch instead of a checkbox, matching the "Toggle switches" section of the Prism theme.

f.input :active, as: :prism_toggle

Reuses BooleanInput's hidden-field/checked-value/name logic verbatim — only the wrapping markup changes, so submitted params are identical to a normal as: :boolean input.

Instance Method Summary collapse

Instance Method Details

#input_html_optionsObject



22
23
24
# File 'lib/formtastic/inputs/prism_toggle_input.rb', line 22

def input_html_options
  super.merge(class: [super[:class], "prism-toggle-input"].reject(&:blank?).join(" "))
end

#label_html_optionsObject



26
27
28
# File 'lib/formtastic/inputs/prism_toggle_input.rb', line 26

def label_html_options
  super.merge(class: [super[:class], "prism-toggle"].reject(&:blank?).join(" "))
end

#label_with_nested_checkboxObject



14
15
16
17
18
19
20
# File 'lib/formtastic/inputs/prism_toggle_input.rb', line 14

def label_with_nested_checkbox
  builder.label(
    method,
    check_box_html + template.(:span, "", class: "prism-toggle-track") + label_text,
    label_html_options
  )
end