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, #form_html, get_class, #initialize, #key, #label, #multi_inputs?, #no_edit?, #no_view?, type_name, #validate, #value, #view

Constructor Details

This class inherits a constructor from Ezframe::TypeBase

Instance Method Details

#db_typeObject



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

def db_type
  return "text"
end

#form(opts = {}) ⇒ Object



113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/ezframe/column_type.rb', line 113

def form(opts = {})
  return nil if no_edit? && !opts[:force]
  if @attribute[:size]
    val = @value
    if val && val.length>0
      val.gsub!(/\n/, "<br>")
    end
    h = Ht.textarea(name: self.key, class: "textarea-size-#{@attribute[:size]}", label: @attribute[:label], child: val)
  else
    h = Ht.input(type: "text", name: self.key, label: @attribute[:label], value: @value || "")
  end
  return h
end

#normalize(val) ⇒ Object



100
101
102
103
104
105
106
107
# File 'lib/ezframe/column_type.rb', line 100

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



109
110
111
# File 'lib/ezframe/column_type.rb', line 109

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