Class: CaringForm::Field::Collection

Inherits:
Base
  • Object
show all
Defined in:
lib/caring_form/field/collection.rb

Direct Known Subclasses

CheckBox, CheckBoxes, LookingFor, RadioButtons

Instance Attribute Summary

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#default_label, #initialize, register, #render

Constructor Details

This class inherits a constructor from CaringForm::Field::Base

Instance Method Details

#apply_to_model(klass) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/caring_form/field/collection.rb', line 14

def apply_to_model(klass)
  super
  if (range = valid_values)
    klass.send(:validates_inclusion_of, name, :allow_blank => true,
               :in => range, :message => message)
  end
end

#input_properties(form, options = {}) ⇒ Object



22
23
24
25
26
# File 'lib/caring_form/field/collection.rb', line 22

def input_properties(form, options = {})
  super.tap do |req|
    req[:include_blank] = false
  end
end

#simple_typeObject



10
11
12
# File 'lib/caring_form/field/collection.rb', line 10

def simple_type
  self.as || :select
end