Class: Ezframe::TextType
Direct Known Subclasses
BirthdayType, DateType, EmailType, IntType, JpnameType, KatakanaType, PasswordType, TelType, TextareaType, TimeType, ZipcodeType
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
Instance Method Details
127
128
129
|
# File 'lib/ezframe/column_type.rb', line 127
def db_type
return "text"
end
|
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
|