Reputation: 565
I am using Dropzone and try to combine it with normal form so I read this tutorial https://github.com/enyo/dropzone/wiki/Combine-normal-form-with-Dropzone
and yeah I can do it successfully. However, I want other input text field and submit-button to be outside of form tag (outside of dropzone) so I use css position:absolute
the text input to be above the form and submit-button below form
but I forgot that if I select image to upload the form dropzone's height will extend. so It fail. (see the screenshot)
<form id="my-awesome-dropzone" class="dropzone" style="position:relative">
<div class="dropzone-previews"></div>
Username : <input type="text" name="username" style="position:absolute; top:-50px; left:0px; /> <br/>
Email: <input type="text" name="email" style="position:absolute; top:-40px;left:0px; /> <br/>
<button type="submit" style="position:absolute;top:100px;left:0px;">Submit data and files!</button>
</form>
I even move the button to outside of form and use html5 attribute form="my-awesome-dropzone"
but it's not work. How could I do?
Upvotes: 3
Views: 2174
Reputation: 1054
this seems to be a strange way of achieving what you want. I checked the documentation and in the Tips & Tricks section (https://docs.dropzone.dev/misc/tips) it clearly states that you can put an element inside your dropzone element with the class dz-message and dropzone will not create the message for you. So I would suggest that you do like I've done and above your submit button place the following element:
<div class="dz-message">
<div>Upload file here</div>
</div>
The negative aspect is that dictDefaultMessage
isn't then honoured.
Also, if javascript is disabled then the div will still show, in which case add this to your css:
<noscript>
<style>
.dz-message {display:none;}
</style>
</noscript>
Upvotes: 0
Reputation: 1688
You could do it this way, a padding of 20px
to the form at bottom, and append button
to absolute, bottom: 0px
, and it will be at end of form, even if there's uploaded images.
$(function(){
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone("#my-awesome-dropzone", { url: "/file/post"});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://www.dropzonejs.com/new-js/dropzone.js"></script>
<link href="http://www.dropzonejs.com/css/dropzone.css" rel="stylesheet"/>
<form id="my-awesome-dropzone" class="dropzone" style="position:relative; padding-bottom: 30px;">
<input type="email" name="username" /><br>
<input type="password" name="password" /><br>
<div class="dropzone-previews"></div>
<button type="submit" style="position: absolute; bottom: 0px;">Submit data and files!</button>
</form>
Upvotes: 1
Reputation: 12400
I think your problem of dropzone overlapping submit button is due to form having style="position:relative"
and button having style="position:absolute;top:100px;left:0px;"
. Remove both of them.
Upvotes: 0