Sha256: e20302ba3c8408fe852adcff453dbab79b47daf9c4082d880e99eedd8f183ccb

Contents?: true

Size: 949 Bytes

Versions: 5

Compression:

Stored size: 949 Bytes

Contents

class EnumField < StringField
  # class << self
  #   undef search_terms_set
  # end
  # 
  # def self.to_html_field(record, field, value)
  #   if value.nil? && !field.default.nil?
  #     value = field.default
  #   end
  #   value = value.to_s
  # 
  #   select_options = field.values.collect do |enum_value|
  #     options = {value: enum_value}
  #     options[:selected] = 'selected' if value == enum_value
  #     Hpricot::Elem.new('option', options, [Hpricot::Text.new(enum_value)])
  #   end
  # 
  #   if field.show_blank || !field.required
  #     options = {value: ''}
  #     text = field.blank_text || 'None'
  #     options[:selected] = 'selected' if value == ''
  #     select_options.unshift(Hpricot::Elem.new('option', options, [Hpricot::Text.new(text)]))
  #   end
  # 
  #   Hpricot::Elem.new('select', {name: field.name}, select_options)
  # end
  
  def default_input_type
    :enum
  end
end

Field::TYPES['enum'] = EnumField

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
yodel-0.0.7 lib/yodel/models/core/fields/enum_field.rb
yodel-0.0.4 lib/yodel/models/core/fields/enum_field.rb
yodel-0.0.3 lib/yodel/models/core/fields/enum_field.rb
yodel-0.0.2 lib/yodel/models/core/fields/enum_field.rb
yodel-0.0.1 lib/yodel/models/core/fields/enum_field.rb