Class: Caisson::Helpers::Form::Field::Checkbox

Inherits:
Base
  • Object
show all
Defined in:
lib/caisson/helpers/form/field/checkbox.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Caisson::Helpers::Form::Field::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Caisson::Helpers::Form::Field::Base

Instance Method Details

#build(name, selected, options = {}) ⇒ Object

************************************************************************************* PUBLIC INSTANCE METHODS *************************************************************************************



9
10
11
12
13
14
15
16
# File 'lib/caisson/helpers/form/field/checkbox.rb', line 9

def build(name, selected, options={})
  content = []
  content << hidden_field_tag(name, '0', id: nil)
  content << check_box_tag(name, '1', parse_selected(selected), generate_attributes(name, options))
  content << options.delete(:label)

  return (:label, content.join("\n").html_safe, :for => name.parameterize.underscore)
end