Created
December 22, 2008 10:29
-
-
Save alx/38952 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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