Class: Ezframe::TextType

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

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?, #type, type_name, #use_view_format, #validate, #value, #view

Constructor Details

This class inherits a constructor from Ezframe::TypeBase

Instance Method Details

#db_typeObject



141
142
143
# File 'lib/ezframe/column_type.rb', line 141

def db_type
  return "text"
end

#form(opts = {}) ⇒ Object



131
132
133
134
135
136
137
138
139
# File 'lib/ezframe/column_type.rb', line 131

def form(opts = {})
  return nil if no_edit? && !opts[:force]
  key = self.key
  key ="#{key}#{opts[:key_suffix]}" if opts[:key_suffix]
  h = Ht.input(type: "text", name: key, label: @attribute[:label], value: @value || "")
  h[:class] = @attribute[:class] if @attribute[:class]
  h[:after]  = make_error_box(key)
  return h
end

#normalize(val) ⇒ Object



118
119
120
121
122
123
124
125
# File 'lib/ezframe/column_type.rb', line 118

def normalize(val)
  return nil unless val
  val = val.dup.to_s
  val.gsub!(/ /, " ")
  # val.gsub!(/\s+/, " ")
  val.strip!
  return val
end

#value=(val) ⇒ Object



127
128
129
# File 'lib/ezframe/column_type.rb', line 127

def value=(val)
  @value = normalize(val)
end