Permalink
Browse files

Nifty paperclip_file_field

  • Loading branch information...
quirkey committed Nov 11, 2009
1 parent 780ec0e commit f4a13a9961fef3dd709234fe17dff35c08aa1df8
Showing with 17 additions and 0 deletions.
  1. +17 −0 lib/qadmin/form_builder.rb
View
@@ -13,6 +13,23 @@ def labeled_#{field}(method, options = {})
end
EOT
end
+
+ def paperclip_file_field(method, options = {})
+ html = %{<p>}
+ label_text = options.delete(:label) || method.to_s.humanize
+ if object.send("#{method}?")
+ html << %{
+ #{label(method, label_text)}
+ <em>View existing #{label_text}:</em>
+ <a href="#{object.send(method).url}" target="_blank">#{object.send("#{method}_file_name")}</a>
+ <br />
+ }
+ end
+ html << %{
+ #{file_field(method, options)}
+ </p>}
+ html
+ end
def text_field_with_hint(method, options = {})
if object.send(method).blank?

0 comments on commit f4a13a9

Please sign in to comment.