Class: Bureaucrat::Widgets::FileInput

Inherits:
Input show all
Defined in:
lib/bureaucrat/widgets.rb

Direct Known Subclasses

ClearableFileInput

Constant Summary

Constants included from Utils

Utils::ESCAPES

Instance Attribute Summary

Attributes inherited from Widget

#attrs, #is_required

Instance Method Summary collapse

Methods inherited from Widget

#build_attrs, #hidden?, id_for_label, #initialize, #initialize_copy

Methods included from Utils

#blank_value?, #conditional_escape, #escape, #flatatt, #format_string, #make_bool, #make_float, #mark_safe, #pretty_name

Constructor Details

This class inherits a constructor from Bureaucrat::Widgets::Widget

Instance Method Details

#has_changed?(initial, data) ⇒ Boolean

Returns:

  • (Boolean)


146
147
148
# File 'lib/bureaucrat/widgets.rb', line 146

def has_changed?(initial, data)
  data.nil?
end

#input_typeObject



150
151
152
# File 'lib/bureaucrat/widgets.rb', line 150

def input_type
  'file'
end

#needs_multipart?Boolean

Returns:

  • (Boolean)


154
155
156
# File 'lib/bureaucrat/widgets.rb', line 154

def needs_multipart?
  true
end

#render(name, value, attrs = nil) ⇒ Object



138
139
140
# File 'lib/bureaucrat/widgets.rb', line 138

def render(name, value, attrs=nil)
  super(name, nil, attrs)
end

#value_from_formdata(data, name) ⇒ Object



142
143
144
# File 'lib/bureaucrat/widgets.rb', line 142

def value_from_formdata(data, name)
  data[name] && TemporaryUploadedFile.new(data[name])
end