Class: Ezframe::IntType
Instance Attribute Summary
Attributes inherited from TypeBase
#attribute, #error, #parent
Instance Method Summary
collapse
Methods inherited from TextType
#normalize
Methods inherited from TypeBase
#db_value, #form_html, get_class, #initialize, #key, #label, #multi_inputs?, #no_edit?, #no_view?, #normalize, type_name, #validate, #value
Instance Method Details
185
186
187
|
# File 'lib/ezframe/column_type.rb', line 185
def db_type
return "int"
end
|
178
179
180
181
182
183
|
# File 'lib/ezframe/column_type.rb', line 178
def form(opts = {})
return nil if no_edit? && !opts[:force]
h = Ht.input(type: "number", name: self.key, label: @attribute[:label], value: @value || "")
h[:class] = @attribute[:class] if @attribute[:class]
return h
end
|
#value=(v) ⇒ Object
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
# File 'lib/ezframe/column_type.rb', line 157
def value=(v)
if v.nil?
default = @attribute[:default]
if default
@value = default
else
@value = nil
end
return
end
if v.nil?
@value = nil
return
end
if v.is_a?(String)
v = v.tr("0-9", "0-9").strip
end
@value = v.to_i
end
|
#view(opts = {}) ⇒ Object
152
153
154
155
|
# File 'lib/ezframe/column_type.rb', line 152
def view(opts = {})
return nil if no_view? && !opts[:force]
return @value.to_i.add_comma
end
|