Skip to content

Instantly share code, notes, and snippets.

@jimjeffers
Created October 29, 2013 20:31
Show Gist options
  • Save jimjeffers/7222039 to your computer and use it in GitHub Desktop.
Save jimjeffers/7222039 to your computer and use it in GitHub Desktop.
Form used to create a photo w/ Carrier Wave Direct.
<!-- Form Container Start -->
<div class="form-container">
<% if params[:key].nil? %>
<%= direct_upload_form_for @uploader, html: {:class => "form"} do |f| %>
<p class="field">
<label>Select a photo to upload:</label><br>
<%= f.file_field :image %>
</p>
<p class="field">
<%= f.submit "Upload Image",
type: "image",
src: "#{ENV['MEDIA_HOST']}/images/btn-submit.gif" %>
</p>
<% end %>
<% else %>
<%= form_for [@business, @photo], html: {:class => "form"} do |f| %>
<% if @photo.errors.any? %>
<div class="errors-explanation">
<h2><%= pluralize(@photo.errors.count, "error") %>
prohibited this photo from being saved.</h2>
<ul class="errors-list">
<% for error in @photo.errors.full_messages %>
<li class="errors-message"><%= error %></li>
<% end %>
</ul>
</div>
<% end %>
<%= f.hidden_field :key %>
<p class="field">
<%= f.label :description, "Description / Credits" %><br>
<%= f.text_area :description, size: "60x10" %>
</p>
<p class="field">
<%= f.submit "save image",
type: "image",
src: "#{ ENV['MEDIA_HOST'] }/images/btn-submit.gif" %>
</p>
<% end %>
<% end %>
</div>
<!-- Form Container End -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment