Skip to content

Instantly share code, notes, and snippets.

@alx
Created December 22, 2008 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alx/38952 to your computer and use it in GitHub Desktop.
Save alx/38952 to your computer and use it in GitHub Desktop.
def media_upload_form(options = {}, &block)
form :action => url(:upload) do
#
# You can disallow tag text_field by setting options[:tags_enabled] to 0
#
if options[:tags_enabled].nil? or options[:tags_enabled] != 0
text_field(:name => "tags", :label => options[:tags_label] || "Tags")
end
#
# Delimiter is set by default, you have to set options[:delimiter_enabled]
# to allow user to set it
#
if options[:delimiter_enabled] == 1
text_field(:name => "delimiter", :label => options[:delimiter_label] || "Delimiter")
end
file_field(:name => "file", :id => "media_file", :label => options[:file_label] || "File")
submit(options[:submit_label] || "Upload", :id => "media_button")
end
end
#### The view
<div id="upload">
<h2>Upload a new file</h2>
<%= media_upload_form %>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment