Class: FactoryForm::MultipleChoice
- Defined in:
- lib/factoryform/multiple_choice.rb
Constant Summary collapse
- FIELD_TYPE =
attr_accessor :type # select_box, check_box, radio_button(:default)
["select_box", "check_box", "radio_button"]
Instance Attribute Summary collapse
-
#values ⇒ Object
Option values.
Attributes inherited from Field
#field_type, #hint, #id, #label, #required, #unique, #validation_format
Instance Method Summary collapse
- #add_option(value) ⇒ Object
-
#initialize(options = {}) ⇒ MultipleChoice
constructor
A new instance of MultipleChoice.
- #remove_option(value) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ MultipleChoice
Returns a new instance of MultipleChoice.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/factoryform/multiple_choice.rb', line 7 def initialize(={}) [:field_type] ||= "radio_button" super() # Unique is always false @unique = false if [:values] && [:values].length > 1 @values = [:values] else raise(ParameterExpectedException, "Missing option values (at least two)") end check_field_type end |
Instance Attribute Details
#values ⇒ Object
Option values
3 4 5 |
# File 'lib/factoryform/multiple_choice.rb', line 3 def values @values end |
Instance Method Details
#add_option(value) ⇒ Object
24 25 26 |
# File 'lib/factoryform/multiple_choice.rb', line 24 def add_option(value) @values.push(value) end |
#remove_option(value) ⇒ Object
28 29 30 |
# File 'lib/factoryform/multiple_choice.rb', line 28 def remove_option(value) @values.delete(value) end |