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, get_class, #initialize, #key, #label, #make_error_box, #multi_inputs?, #no_edit?, #no_view?, #normalize, #type, type_name, #use_view_format, #value, #value=

Constructor Details

This class inherits a constructor from Ezframe::TypeBase

Instance Method Details

#db_typeObject



326
327
328
# File 'lib/ezframe/column_type.rb', line 326

def db_type
  return "text"
end

#form(opts = {}) ⇒ Object



317
318
319
320
321
322
323
324
# File 'lib/ezframe/column_type.rb', line 317

def form(opts = {})
  return nil if no_edit? && !opts[:force]
  @items ||= @attribute[:item]
  h = Ht.select(class: %w[browser-default], name: self.key, label: @attribute[:label], item: @items, value: @value)
  h[:class] = @attribute[:class] if @attribute[:class]
  h[:after] = make_error_box(self.key)
  return h
end

#validate(val) ⇒ Object



338
339
340
# File 'lib/ezframe/column_type.rb', line 338

def validate(val)
  return nil
end

#view(opts = {}) ⇒ Object



330
331
332
333
334
335
336
# File 'lib/ezframe/column_type.rb', line 330

def view(opts = {})
  return nil if no_view? && !opts[:force]
  item = @attribute[:item]
  # EzLog.debug("select.view: @value=#{@value}, #{@value.class}, item=#{item}, result=#{item[@value]}")
  return nil unless @value
  return item[@value.to_s.to_sym]
end