Class: Ezframe::SelectType

Inherits:
TypeBase show all
Defined in:
lib/ezframe/column_type.rb

Direct Known Subclasses

PrefectureType

Instance Attribute Summary

Attributes inherited from TypeBase

#attribute, #error, #parent

Instance Method Summary collapse

Methods inherited from TypeBase

#db_value, #form_html, get_class, #initialize, #key, #label, #multi_inputs?, #no_edit?, #no_view?, #normalize, type_name, #validate, #value, #value=

Constructor Details

This class inherits a constructor from Ezframe::TypeBase

Instance Method Details

#db_typeObject



242
243
244
# File 'lib/ezframe/column_type.rb', line 242

def db_type
  return "text"
end

#form(opts = {}) ⇒ Object



234
235
236
237
238
239
240
# File 'lib/ezframe/column_type.rb', line 234

def form(opts = {})
  return nil if no_edit? && !opts[:force]
  # puts "selectType: #{@attribute[:item].inspect}"
  h = { tag: "select", name: self.key, label: @attribute[:label], item: @attribute[:item], value: @value }
  h[:class] = @attribute[:class] if @attribute[:class]
  return h
end

#view(opts = {}) ⇒ Object



246
247
248
249
250
# File 'lib/ezframe/column_type.rb', line 246

def view(opts = {})
  return nil if no_view? && !opts[:force]
  item = @attribute[:item]
  return item[@value]
end