mardi 29 mars 2016

Rails Nested form and Dropzone

i'm striving to make a simple dropzone work on a product form with nested images form but after search a lot and change the code i would like to know if dropzone support nested form, because i can't find it in the doc.

anyway my code is:

$('#images').dropzone({// PDF dropzone element
  maxFilesize: 2, // Set the maximum file size to 256 MB
   maxFiles: 10,
    dictDefaultMessage: "drop your images here",
    paramName: "product[images_attributes][][foto]",
  addRemoveLinks: true, // Don't show remove links on dropzone itself.
 dictRemoveFile: 'Remover'

    // rest of code
 //
 });

<

%= form_for @product, :html => {:multipart => true}  do |p| %>
  <div class="block margin_top">

 <%= p.fields_for(:images,  html: { multipart: true, id: "images",class: "dropzone"}) do |i| %>
     <div class="fallback">

            <%= i.file_field :photo %><br>
            <%= i.submit "Save" %>
          </div>
    <% end %>
</div>

Aucun commentaire:

Enregistrer un commentaire