Class: CheckboxGroup
- Inherits:
-
Group
- Object
- BasicField
- Group
- CheckboxGroup
- Defined in:
- lib/formalize/field.rb
Instance Method Summary collapse
Methods inherited from Group
Methods inherited from BasicField
#errors, #errors=, #initialize, #input, #valid?, #validate, #validate_format, #validate_length, #validate_presence, #value
Methods included from Helpers
#tag, #tag_attributes, #tag_content
Constructor Details
This class inherits a constructor from Group
Instance Method Details
#choice(value, choice_opts = {}) ⇒ Object
151 152 153 154 |
# File 'lib/formalize/field.rb', line 151 def choice(value, choice_opts={}) choice_opts[:value] = value @choices.push(CheckboxField.new(@opts[:name], choice_opts)) end |
#value=(values) ⇒ Object
155 156 157 158 |
# File 'lib/formalize/field.rb', line 155 def value=(values) @opts[:value] = values @choices.each { |choice| choice.opts[:checked] = (values.include?(choice.opts[:value].to_s)) } end |