Class: Lore::GUI::File

Inherits:
Form_Element show all
Defined in:
lib/lore/gui/form_element.rb

Overview

Form file element (<input type=“file” …>). Subclass of Form_Element.

Instance Attribute Summary

Attributes inherited from Form_Element

#attribute_id, #attribute_label, #attribute_name, #attribute_range, #attribute_table, #attribute_value, #id, #mode, #on_change, #on_click, #style, #style_class, #template, #template_file

Instance Method Summary collapse

Methods inherited from Form_Element

for, #label, #onblur, #onfocus, #print, #set_attribute_style, #set_attribute_value, #set_mode, #setup

Constructor Details

#initialize(_table, _attrib_name, _attrib_label, _attrib_range = nil, _attrib_value = nil) ⇒ File

{{{



192
193
194
# File 'lib/lore/gui/form_element.rb', line 192

def initialize(_table, _attrib_name, _attrib_label, _attrib_range=nil, _attrib_value=nil)
  setup(_table, _attrib_name, _attrib_label, _attrib_range, _attrib_value)
end

Instance Method Details

#stringObject



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/lore/gui/form_element.rb', line 196

def string
  if @mode == :mutable then
    template = @template.new('file.rhtml')
  elsif @mode == :readonly then
    template = @template.new('text_readonly.rhtml')
  end
  # to avoid value=""
  if @attribute_value == '' then @attribute_value = nil end
  if @mode == :mutable then
    if @attribute_table.to_s == '' then
      name = @attribute_name 
    else
      name = @attribute_table + '.' + @attribute_name
    end
    
    data = {
      :id    => @attribute_id, 
      :class => @style_class.to_s, 
      :name  => name, 
      :value => @attribute_value, 
      :style => @style
    }
  elsif @mode == :readonly then
    data[:value] = @attribute_value 
  end
  template.set_data(:attributes => data)
  template.string()
end