Class: FormtasticBootstrap::Inputs::BooleanInput

Inherits:
Formtastic::Inputs::BooleanInput
  • Object
show all
Includes:
Base
Defined in:
lib/formtastic-bootstrap/inputs/boolean_input.rb

Instance Method Summary collapse

Methods included from FormtasticBootstrap::Inputs::Base::Wrapping

#add_on_content, #add_on_wrapper_classes, #bootstrap_wrapping, #form_group_wrapping, #input_content, #prepended_or_appended?

Methods included from FormtasticBootstrap::Inputs::Base::Labelling

#label_html, #label_html_options

Methods included from FormtasticBootstrap::Inputs::Base::Hints

#hint_html

Methods included from FormtasticBootstrap::Inputs::Base::Errors

#error_first_html, #error_html, #error_list_html, #error_none_html, #error_sentence_html

Methods included from FormtasticBootstrap::Inputs::Base::Html

#form_control_input_html_options, #input_html_options

Instance Method Details

#checkbox_wrapping(&block) ⇒ Object



31
32
33
34
35
36
# File 'lib/formtastic-bootstrap/inputs/boolean_input.rb', line 31

def checkbox_wrapping(&block)
  template.(:div,
    template.capture(&block).html_safe,
    wrapper_html_options
  )
end

#hidden_field_htmlObject



19
20
21
# File 'lib/formtastic-bootstrap/inputs/boolean_input.rb', line 19

def hidden_field_html
  template.hidden_field_tag(input_html_options[:name], unchecked_value, :id => nil, :disabled => input_html_options[:disabled] )
end

#label_with_nested_checkboxObject



23
24
25
26
27
28
29
# File 'lib/formtastic-bootstrap/inputs/boolean_input.rb', line 23

def label_with_nested_checkbox
  builder.label(
    method,
    label_text_with_embedded_checkbox,
    label_html_options
  )
end

#render_label?Boolean

Skip rendering of .form-label in #bootstrap_wrapping

Returns:

  • (Boolean)


8
9
10
# File 'lib/formtastic-bootstrap/inputs/boolean_input.rb', line 8

def render_label?
  false
end

#to_htmlObject



12
13
14
15
16
17
# File 'lib/formtastic-bootstrap/inputs/boolean_input.rb', line 12

def to_html
  bootstrap_wrapping do
    hidden_field_html <<
    label_with_nested_checkbox
  end
end

#wrapper_html_optionsObject



38
39
40
41
42
# File 'lib/formtastic-bootstrap/inputs/boolean_input.rb', line 38

def wrapper_html_options
  super.tap do |options|
    options[:class] = (options[:class].split + ["checkbox"]).join(" ")
  end
end